Jump to content

Need Help on this! Reward for solution.


zrueda

Recommended Posts

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>

 

Link to comment
Share on other sites

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 ...

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.