SkyRanger Posted March 30, 2008 Share Posted March 30, 2008 Ok, not sure what the problem is but here is the code: Page with link: <A HREF="rinfo.php?pid=1"><img src="images/info.gif" alt="feature info" border="0" width="12" height="12" /></a> Going to: // Make a MySQL Connection mysql_connect("localhost", "username", "passwrd") or die(mysql_error()); mysql_select_db("dbase") or die(mysql_error()); $result = mysql_query("SELECT * FROM pop where pid='$pid'") <- Doesn't work but when i put in: $result = mysql_query("SELECT * FROM pop where pid='1'") <- This works or die(mysql_error()); while($row = mysql_fetch_array($result)) { echo "<strong>".$row['ptitle']."</strong>"; echo "<br><br>"; echo nl2br($row['pdesc']); echo "<br><br>"; } All I am getting is a white page. Even when I put in the echo $pid; nothing shows When I put in echo "Some test"; This works. Quote Link to comment https://forums.phpfreaks.com/topic/98572-not-sure-why/ Share on other sites More sharing options...
inaba Posted March 30, 2008 Share Posted March 30, 2008 I think the right code will be: mysql_query("SELECT * FROM pop where pid='".$pid."'"); thaT is $pid should not be inside double quotes. Quote Link to comment https://forums.phpfreaks.com/topic/98572-not-sure-why/#findComment-504491 Share on other sites More sharing options...
SkyRanger Posted March 30, 2008 Author Share Posted March 30, 2008 No, that didn't fix it. Quote Link to comment https://forums.phpfreaks.com/topic/98572-not-sure-why/#findComment-504492 Share on other sites More sharing options...
don117 Posted March 30, 2008 Share Posted March 30, 2008 Was $pid initialized? Perhaps, you should initialize it and assing something to it. <?php $pid = $_GET['pid']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/98572-not-sure-why/#findComment-504494 Share on other sites More sharing options...
ohdang888 Posted March 30, 2008 Share Posted March 30, 2008 put this: or die(mysql_error()); at the end of the query and see what errors you get. Quote Link to comment https://forums.phpfreaks.com/topic/98572-not-sure-why/#findComment-504496 Share on other sites More sharing options...
SkyRanger Posted March 30, 2008 Author Share Posted March 30, 2008 put this: or die(mysql_error()); at the end of the query and see what errors you get. No errors Quote Link to comment https://forums.phpfreaks.com/topic/98572-not-sure-why/#findComment-504498 Share on other sites More sharing options...
SkyRanger Posted March 30, 2008 Author Share Posted March 30, 2008 Was $pid initialized? Perhaps, you should initialize it and assing something to it. <?php $pid = $_GET['pid']; ?> Thanks don117 that fixed it. Quote Link to comment https://forums.phpfreaks.com/topic/98572-not-sure-why/#findComment-504500 Share on other sites More sharing options...
ohdang888 Posted March 30, 2008 Share Posted March 30, 2008 well then i think it's proabably because there is nothing stored in $pid where are you defining $pid? and try this: $result = mysql_query("SELECT * FROM pop WHERE pid='{$pid}' ") Quote Link to comment https://forums.phpfreaks.com/topic/98572-not-sure-why/#findComment-504502 Share on other sites More sharing options...
inaba Posted March 30, 2008 Share Posted March 30, 2008 $q="SELECT * FROM pop where pid='$pid'"; echo $q; chech what $q holds. Quote Link to comment https://forums.phpfreaks.com/topic/98572-not-sure-why/#findComment-504503 Share on other sites More sharing options...
redarrow Posted March 30, 2008 Share Posted March 30, 2008 link <A HREF="rinfo.php?pid=1"><img src="images/info.gif" alt="feature info" border="0" width="12" height="12" /></a> <?php mysql_connect("localhost", "username", "passwrd") or die(mysql_error()); mysql_select_db("dbase") or die(mysql_error()); $sql = "SELECT * FROM pop where pid=' ".$_GET['pid']."' "; $sql_result=mysql-query($sql)or die(mysql_error()); while($row = mysql_fetch_array($result)) { echo "<strong>".$row['ptitle']."</strong>"; echo "<br><br>"; echo nl2br($row['pdesc']); echo "<br><br>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/98572-not-sure-why/#findComment-504597 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.