joshgarrod Posted January 27, 2008 Share Posted January 27, 2008 i have two scripts, the first displays a list of article names generated from a table, the user would then click a link, and depending on which link they click, the script is supposed to use the id number on the next script on the viewArticle page and draw that information from the table and display it. but i keep getting this file does not exist. where am i going wrong please? Article list: <?php $con = mysql_connect("localhost","fghm1","ixfgdmghm"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("bncvm", $con); $query = "SELECT * FROM `Animals` ORDER BY `ID`"; $result = mysql_query($query); $num=mysql_num_rows($result); $i=0; while ($i < $num) { $ArtID=mysql_result($result,$i,"ID"); $Article=mysql_result($result,$i,"Article"); $url="index.php?page="; echo '<tr><td width=5></td><td align=center><a href="index.php?page=viewArticle">'.$Article.'</a></td></tr>'; ++$i; } ?> View article script <?php $con = mysql_connect("localhost","fghjhk","ifghkhjk8"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("sfsgh", $con); $page = $_GET['ID']; // This will be the ID of the page $page = mysql_real_escape_string(strip_tags($page)); $query = mysql_query("SELECT * FROM Animals WHERE `ID` = '$page'"); if(mysql_num_rows($query)==0){ die("Sorry, but that page does not exists $row"); }else{ while($row = mysql_fetch_array($query)){ echo $row['Article'] . "<br>"; echo $row['Text'] . "<br>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/88085-solved-where-am-i-going-wrong/ Share on other sites More sharing options...
revraz Posted January 27, 2008 Share Posted January 27, 2008 You don't seem to be setting the ID in your URL echo '<tr><td width=5></td><td align=center><a href="index.php?page=viewArticle">'.$Article.'</a></td></tr>'; Quote Link to comment https://forums.phpfreaks.com/topic/88085-solved-where-am-i-going-wrong/#findComment-450648 Share on other sites More sharing options...
joshgarrod Posted January 27, 2008 Author Share Posted January 27, 2008 how do u mean Quote Link to comment https://forums.phpfreaks.com/topic/88085-solved-where-am-i-going-wrong/#findComment-450654 Share on other sites More sharing options...
revraz Posted January 27, 2008 Share Posted January 27, 2008 Where do you GET this from? $page = $_GET['ID']; // This will be the ID of the page Quote Link to comment https://forums.phpfreaks.com/topic/88085-solved-where-am-i-going-wrong/#findComment-450659 Share on other sites More sharing options...
joshgarrod Posted January 27, 2008 Author Share Posted January 27, 2008 im not sure, someone was helping me earlier but is offline now. do you see what i want to do? Quote Link to comment https://forums.phpfreaks.com/topic/88085-solved-where-am-i-going-wrong/#findComment-450662 Share on other sites More sharing options...
PHP Monkeh Posted January 27, 2008 Share Posted January 27, 2008 Modify this line: echo '<tr><td width=5></td><td align=center><a href="index.php?page=viewArticle">'.$Article.'</a></td></tr>'; to be: echo '<tr><td width=5></td><td align=center><a href="index.php?page=viewArticle&ID=$ArtID">'.$Article.'</a></td></tr>'; that's on the article list page. Quote Link to comment https://forums.phpfreaks.com/topic/88085-solved-where-am-i-going-wrong/#findComment-450665 Share on other sites More sharing options...
joshgarrod Posted January 27, 2008 Author Share Posted January 27, 2008 it still says the page doesnt exists? Quote Link to comment https://forums.phpfreaks.com/topic/88085-solved-where-am-i-going-wrong/#findComment-450667 Share on other sites More sharing options...
revraz Posted January 27, 2008 Share Posted January 27, 2008 Is the ID blank when you hover over the link? echo "<tr><td width=5></td><td align=center><a href='index.php?page=viewArticle&ID=$ArtID'>$Article</a></td></tr>"; Quote Link to comment https://forums.phpfreaks.com/topic/88085-solved-where-am-i-going-wrong/#findComment-450672 Share on other sites More sharing options...
PHP Monkeh Posted January 27, 2008 Share Posted January 27, 2008 Does your switch/if statement have a condition for page = viewArticle? Or are you just including $_GET['page'].php Quote Link to comment https://forums.phpfreaks.com/topic/88085-solved-where-am-i-going-wrong/#findComment-450673 Share on other sites More sharing options...
joshgarrod Posted January 27, 2008 Author Share Posted January 27, 2008 the link just looks like this 'http://www.mysite.co.uk/info/index.php?page=viewArticle&ID=$ArtID' i am not too sure what is going on it, someone was helping me earlier and has gone offline, sorry Quote Link to comment https://forums.phpfreaks.com/topic/88085-solved-where-am-i-going-wrong/#findComment-450675 Share on other sites More sharing options...
revraz Posted January 27, 2008 Share Posted January 27, 2008 Use the code I posted above instead, it needs to be surrounded by double quotes and not single ones. Quote Link to comment https://forums.phpfreaks.com/topic/88085-solved-where-am-i-going-wrong/#findComment-450678 Share on other sites More sharing options...
joshgarrod Posted January 27, 2008 Author Share Posted January 27, 2008 brilliant guys, thanks v muc for your help. works fine now, thanks Quote Link to comment https://forums.phpfreaks.com/topic/88085-solved-where-am-i-going-wrong/#findComment-450681 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.