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. 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. 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. 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']; ?> 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. 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 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. 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}' ") 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. 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>"; } ?> Link to comment https://forums.phpfreaks.com/topic/98572-not-sure-why/#findComment-504597 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.