anticore Posted March 15, 2006 Share Posted March 15, 2006 do i have a syntax error around here ? it just outputs a blank page.. [code]mysql_connect($host,$user,$pass) or die("COULD NOT CONNECT TO DB");mysql_select_db($db) or die("COULD NOT SELECT DB");//echo " connected ...";//run query$query = "SELECT * FROM user_rides WHERE yearcat=".$_REQUEST['yearcat'];if ($r = mysql_query($query) or die(mysql_error()){//printwhile ($row = mysql_fetch_array ($r)){ print "{$row['name']}"; }else {die('error');}[/code] Quote Link to comment Share on other sites More sharing options...
Balmung-San Posted March 16, 2006 Share Posted March 16, 2006 turn the print "{$row['name']}"; into print "{".$row['name']."}"; Quote Link to comment Share on other sites More sharing options...
keeB Posted March 16, 2006 Share Posted March 16, 2006 Let's go through first, my basic thoughts on how to troubleshoot this issue.Here's the updated code:[code]<?php $debug = true; $connection = mysql_connect($host,$user,$pass) or die("COULD NOT CONNECT TO DB"); mysql_select_db($db) or die("COULD NOT SELECT DB"); $query = "SELECT * FROM user_rides WHERE yearcat=$_REQUEST['yearcat']"; $result = mysql_query($query, $connection) or die ("error in your query"); if ($debug) print $query; if ( mysql_num_rows($result) == 0 ) die ("no results were returned.."); while ($row = mysql_fetch_array ($result)){ if ($debug) { print "<pre>"; print_r($row); print "</pre>"; } print $row['name']; }?>[/code]First I added the [b]$debug = true[/b] I created this for the simple fact that sometimes you need to print out the Query statements if shit goes wrong, and this was just a simple way for me to impliment that for current and future troubleshooting.. I pretty much do this for all queries or strings, on generated forms or data from the DB.. it's a practice that once you impliment correctly, can save you SO much time.Anyway!If you have any questions regarding the specifics.. the syntax I used, the indentation (something your code was seriously lacking) please don't hesitate to ask specifics.Good luck! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.