Site Cloner PHP Script
Bargain Hunter PHP Script
Job Hunter PHP Script
Site Login and Access Control PHP Script

MYSQL Query With Numbers

MYSQL Queries with Numbers

When you make a query with mysql you can use quotes or use no quotes. In most cases, making queries without quoting numbers is safer. For example, examine the 2 queries used in php below:

$command= “SELECT name, email from table where years_experience<10 “;
$command= “SELECT name, email from table where years_experience<’10’ “;
//You may get unexpected results if there are the integers with the value 0 in some of the years_experience rows. In this case, the //column years_experience stores integers.

Although the two queries above may look alike, you can output the data to see how it actually worked. Testing output with mysql commands with phpmyadmin(or mysql console) and using the php script will help ensure you get the results you expect. On various servers, you could get various results.

In a nutshell, values inside of quotes will be strings. If you want numbers…use no quotes. With PHP, anything inside quotes is a string wheras any number without quotes is an integer.