zrueda Posted August 17, 2009 Share Posted August 17, 2009 Ok I have had this problem all day with mysql for my Admin Panel. I get this error. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/bortix/public_html/lockerzinv.com/admin/index.php on line 93 This is the php. Code I will mark which is line 93. With 93. If you solve this I will reward. <?php $con = mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("database", $con) or die(mysql_error()); if ($_POST['newurl'] != '') { $url = $_POST['url']; mysql_query("INSERT INTO urls (url) VALUES ('$url')"); $new_url = true; } else if ($_GET['delete'] != "") { $del = $_GET['delete']; mysql_query("DELETE FROM urls WHERE id='$del'"); $url_delete = true; } ?> <html> <head> <link rel="stylesheet" type="text/css" media="all" href="../main.css" /> <title>Lockerz Invites - Admin Panel</title> </head> <body> <center> <? if ($add_new) { echo '<div class="success"><center>New URL added successfully!</center></div>'; } ?> <? if ($url_delete) { echo '<div class="success"><center>URL Deleted successfully!</center></div>'; } ?> <form name="addurl" action="" method="post"> <input type="hidden" name="newurl" value="1"> <table class='alternate'> <tr bgcolor="b96e00"> <td><font color="ffffff"><center>URL</center></font></td><td></td> </tr> <tr bgcolor="555555"> <td><center><input type="text" name="url" value="" maxlength="1024" size="90%"></center></td> <td><center><input type="submit" value="Add"></center></td> </tr> </table> </form> <br> <table class='alternate'> <tr bgcolor="b96e00"> <td><font color="ffffff"><center>URL List</center></font></td><td></td> </tr> <? $searchresult = mysql_query("SELECT * FROM urls"); 93.while($row = mysql_fetch_array($searchresult)); { echo '<tr bgcolor="555555">'; echo '<td><center><input type="text" name="url" value="' . $row['url'] . '" readonly></center></td>'; echo '<td><center><input type="button" value="Delete" onclick="window.location.href=\'index.php?delete=' . $row['id'] . '\'" alt="Delete"></center></td></tr>'; } ?> </table> </center> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/170580-need-help-on-this-reward-for-solution/ Share on other sites More sharing options...
oni-kun Posted August 17, 2009 Share Posted August 17, 2009 I've looked for 20 minutes and can't find line 93. Regardless, switch all your <? shorthands to <?php. Many servers I've come across don't read them and don't parse the code, throwing it away. Quote Link to comment https://forums.phpfreaks.com/topic/170580-need-help-on-this-reward-for-solution/#findComment-899721 Share on other sites More sharing options...
zrueda Posted August 17, 2009 Author Share Posted August 17, 2009 I've looked for 20 minutes and can't find line 93. Regardless, switch all your <? shorthands to <?php. Many servers I've come across don't read them and don't parse the code, throwing it away. Woops! Ok I put 93. before the line. It should be like 93.while ... Quote Link to comment https://forums.phpfreaks.com/topic/170580-need-help-on-this-reward-for-solution/#findComment-899724 Share on other sites More sharing options...
gergy008 Posted August 17, 2009 Share Posted August 17, 2009 Ok I have had this problem all day with mysql for my Admin Panel. I get this error. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/bortix/public_html/lockerzinv.com/admin/index.php on line 93 This is the php. Code I will mark which is line 93. With 93. If you solve this I will reward. <?php $con = mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("database", $con) or die(mysql_error()); if ($_POST['newurl'] != '') { $url = $_POST['url']; mysql_query("INSERT INTO urls (url) VALUES ('$url')"); $new_url = true; } else if ($_GET['delete'] != "") { $del = $_GET['delete']; mysql_query("DELETE FROM urls WHERE id='$del'"); $url_delete = true; } ?> <html> <head> <link rel="stylesheet" type="text/css" media="all" href="../main.css" /> <title>Lockerz Invites - Admin Panel</title> </head> <body> <center> <? if ($add_new) { echo '<div class="success"><center>New URL added successfully!</center></div>'; } ?> <? if ($url_delete) { echo '<div class="success"><center>URL Deleted successfully!</center></div>'; } ?> <form name="addurl" action="" method="post"> <input type="hidden" name="newurl" value="1"> <table class='alternate'> <tr bgcolor="b96e00"> <td><font color="ffffff"><center>URL</center></font></td><td></td> </tr> <tr bgcolor="555555"> <td><center><input type="text" name="url" value="" maxlength="1024" size="90%"></center></td> <td><center><input type="submit" value="Add"></center></td> </tr> </table> </form> <br> <table class='alternate'> <tr bgcolor="b96e00"> <td><font color="ffffff"><center>URL List</center></font></td><td></td> </tr> <? $searchresult = mysql_query("SELECT * FROM urls"); 93.while($row = mysql_fetch_array($searchresult)); { echo '<tr bgcolor="555555">'; echo '<td><center><input type="text" name="url" value="' . $row['url'] . '" readonly></center></td>'; echo '<td><center><input type="button" value="Delete" onclick="window.location.href=\'index.php?delete=' . $row['id'] . '\'" alt="Delete"></center></td></tr>'; } ?> </table> </center> </body> </html> Maybe you should connect to the database in line 92 too? $searchresult = mysql_query("SELECT * FROM urls", $con); Quote Link to comment https://forums.phpfreaks.com/topic/170580-need-help-on-this-reward-for-solution/#findComment-899728 Share on other sites More sharing options...
zrueda Posted August 17, 2009 Author Share Posted August 17, 2009 Maybe you should connect to the database in line 92 too? $searchresult = mysql_query("SELECT * FROM urls", $con); Already tried that =/. Quote Link to comment https://forums.phpfreaks.com/topic/170580-need-help-on-this-reward-for-solution/#findComment-899730 Share on other sites More sharing options...
oni-kun Posted August 17, 2009 Share Posted August 17, 2009 Here try this, fixed shorthands and rewrote your while loop.. might be worth a try. <?php $con = mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("database", $con) or die(mysql_error()); if ($_POST['newurl'] != '') { $url = $_POST['url']; mysql_query("INSERT INTO urls (url) VALUES ('$url')"); $new_url = true; } else if ($_GET['delete'] != "") { $del = $_GET['delete']; mysql_query("DELETE FROM urls WHERE id='$del'"); $url_delete = true; } ?> <html> <head> <link rel="stylesheet" type="text/css" media="all" href="../main.css" /> <title>Lockerz Invites - Admin Panel</title> </head> <body> <center> <?php if ($add_new) { echo '<div class="success"><center>New URL added successfully!</center></div>'; } ?> <?php if ($url_delete) { echo '<div class="success"><center>URL Deleted successfully!</center></div>'; } ?> <form name="addurl" action="" method="post"> <input type="hidden" name="newurl" value="1"> <table class='alternate'> <tr bgcolor="b96e00"> <td><font color="ffffff"><center>URL</center></font></td><td></td> </tr> <tr bgcolor="555555"> <td><center><input type="text" name="url" value="" maxlength="1024" size="90%"></center></td> <td><center><input type="submit" value="Add"></center></td> </tr> </table> </form> <br> <table class='alternate'> <tr bgcolor="b96e00"> <td><font color="ffffff"><center>URL List</center></font></td><td></td> </tr> <?php $searchresult = mysql_query("SELECT * FROM urls"); while($row = mysql_fetch_array($searchresult)); { echo '<tr bgcolor="555555">'; echo '<td><center><input type="text" name="url" value=" ' . $row['url'] . ' " readonly></center></td>'; echo '<td><center><input type="button" value="Delete" onclick="window.location.href=\"index.php?delete=' . $row['id'].'\" "alt="Delete"></center></td></tr>'; } ?> </table> </center> </body> </html> Edit: And a string escape misplaced Quote Link to comment https://forums.phpfreaks.com/topic/170580-need-help-on-this-reward-for-solution/#findComment-899734 Share on other sites More sharing options...
gergy008 Posted August 17, 2009 Share Posted August 17, 2009 Maybe you should connect to the database in line 92 too? $searchresult = mysql_query("SELECT * FROM urls", $con); Already tried that =/. Will this not work? while($row = mysql_fetch_row($searchresult)); Quote Link to comment https://forums.phpfreaks.com/topic/170580-need-help-on-this-reward-for-solution/#findComment-899735 Share on other sites More sharing options...
zrueda Posted August 17, 2009 Author Share Posted August 17, 2009 Niether of those worked. oni-kun, something was wrong with echo '<td><center><input type="button" value="Delete" onclick="window.location.href=\'index.php?delete=\' . $row['id'].''"alt="Delete"></center></td></tr>'; Quote Link to comment https://forums.phpfreaks.com/topic/170580-need-help-on-this-reward-for-solution/#findComment-899739 Share on other sites More sharing options...
oni-kun Posted August 17, 2009 Share Posted August 17, 2009 Niether of those worked. oni-kun, something was wrong with echo '<td><center><input type="button" value="Delete" onclick="window.location.href=\'index.php?delete=\' . $row['id'].''"alt="Delete"></center></td></tr>'; Fixed it, try it again and see if it works. Quote Link to comment https://forums.phpfreaks.com/topic/170580-need-help-on-this-reward-for-solution/#findComment-899740 Share on other sites More sharing options...
zrueda Posted August 17, 2009 Author Share Posted August 17, 2009 Nope didnt work. Same error on line 93. Someone told me that I need an sql file and another told me it just stores in the database. Quote Link to comment https://forums.phpfreaks.com/topic/170580-need-help-on-this-reward-for-solution/#findComment-899742 Share on other sites More sharing options...
Philip Posted August 17, 2009 Share Posted August 17, 2009 If it comes up with "supplied argument is not a valid MySQL result resource", that means your query failed. You need to echo mysql_error(); on the line after your query to see why it is failing. Quote Link to comment https://forums.phpfreaks.com/topic/170580-need-help-on-this-reward-for-solution/#findComment-899747 Share on other sites More sharing options...
zrueda Posted August 17, 2009 Author Share Posted August 17, 2009 If it comes up with "supplied argument is not a valid MySQL result resource", that means your query failed. You need to echo mysql_error(); on the line after your query to see why it is failing. Can you change what I need for me? I'm kinda a noob at this. Quote Link to comment https://forums.phpfreaks.com/topic/170580-need-help-on-this-reward-for-solution/#findComment-899750 Share on other sites More sharing options...
zrueda Posted August 17, 2009 Author Share Posted August 17, 2009 Now since I know the error its. Table 'bortix_lockerzinv.urls' doesn't exist Quote Link to comment https://forums.phpfreaks.com/topic/170580-need-help-on-this-reward-for-solution/#findComment-899760 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.