hanna1 Posted July 9, 2011 Share Posted July 9, 2011 Hi, I have a php program where the query result will turn to hyperlink. But my problem is when i click the hyperlink search result it returns to blank page, I have a hard time working on this around. I'm newbie in php please help me thanks. :'( Below is my code: //hyperlink_result.php (this code is the hyperlink query result) //echo out construct $sql = "SELECT * FROM search WHERE $construct"; $run = mysql_query($sql); $foundnum = mysql_num_rows($run); if ($foundnum==0) echo "No results found."; else { echo "$foundnum results found!<p>"; while ($runrows= mysql_fetch_array($run)) { //hyperlink search result $title = $runrows['title']; //echo '<p><a href="hyperlink_results.php?id='.$runrows['id'].'">'.$runrows['title'].'</a></p>'; echo "<a href=\"hyperlink_results.php?id=".$runrows['id']."\">".$title."</a>"; } } // hyperlink_results.php (this code will fetch hyperlink query) if (isset($_GET['id'])) { include ("module/conn.php"); $select=mysql_query("SELECT * FROM search WHERE id='".$_GET['id']."'"); $r = mysql_num_rows($select); while($row= mysql_fetch_array($r)){ $des = $row['description']; $title = $row['title']; echo "$des"; echo "$title"; } } } Quote Link to comment https://forums.phpfreaks.com/topic/241477-hyperlink-result-in-php/ Share on other sites More sharing options...
wildteen88 Posted July 9, 2011 Share Posted July 9, 2011 mysql_fetch_array expects a result resource, not the number of rows your query returns. A result resource is returnedby mysql_query. So you need to pass thee $select variable to mysql_fetch_array, not the $r variable $select=mysql_query("SELECT * FROM search WHERE id='".$_GET['id']."'"); $r = mysql_num_rows($select); while($row= mysql_fetch_array($r)){ Change $row= mysql_fetch_array($r) to $row= mysql_fetch_array($select) in hyperlink_results.php Also when developing your scripts you should configure PHP so error_reporting is set to E_ALL and set display_errors to on. You can do this either within your php.ini or within your scripts using error_reporting(E_ALL); ini_set('display_errors', 1); Enabling these two directives will display any PHP errors on screen rather than a blank screen. Quote Link to comment https://forums.phpfreaks.com/topic/241477-hyperlink-result-in-php/#findComment-1240457 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.