$variables in SQL query

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
anticore
Forum Newbie
Posts: 21
Joined: Sat Mar 11, 2006 11:37 pm

$variables in SQL query

Post by anticore »

This Produces nothing..
dont know why :/

Code: Select all

mysql_connect($host,$user,$pass) or die("COULD NOT CONNECT TO DB");
mysql_select_db($db) or die("COULD NOT SELECT DB");
//run query
$query = "SELECT * FROM user_rides WHERE yearcat=".$_REQUEST['yearcat'];

if ($r = mysql_query($query) or die(mysql_error())
{
//print

while ($row = mysql_fetch_array ($r))
{
	print "{$row['name']}";
	
}
else {die('error');
}
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you need to turn on error_reporting (to E_ALL) and/or display_errors .. you have a parse error. hint: count the pairs of braces.
anticore
Forum Newbie
Posts: 21
Joined: Sat Mar 11, 2006 11:37 pm

Post by anticore »

i think theres somehting i gotta change in my PHP INI cause i never get any errors, it just returns blank pages.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

As feyd said, Your missing a brace or 2
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

To "fix" your ini: find the entries in it for "error_reporting" and "display_errors". Make sure they are set to "E_ALL", and "On" respectively. Since there may be multiples of either in the file, make sure to alter only the uncommented line (no leading semicolon.) Restart your web server.
Post Reply