Mysql_fetch_array(): supplied argument is not a valid MySQL
Posted: Fri Nov 13, 2009 3:36 am
Hello.
I'm pretty new into PHP scripting, and I am currently working on a script, where I can select a specific user from a list, and afterward edit them.
But I am getting the following error at the moment:
mysql_fetch_array(): supplied argument is not a valid MySQL result resource.. on line 9
This is the current code:
The error occurs whenever I press the submit at the form.
I'm pretty new into PHP scripting, and I am currently working on a script, where I can select a specific user from a list, and afterward edit them.
But I am getting the following error at the moment:
mysql_fetch_array(): supplied argument is not a valid MySQL result resource.. on line 9
This is the current code:
Code: Select all
<form name="formedituser" method="post" action="index.php?page=admin&sub=editcharacter">
<?php
$query="SELECT * FROM $tbl_name";
$result = mysql_query($query);
if($_POST["user"] != "") {
$selecteduser = $_POST["user"];
$userquery=mysql_query("SELECT * FROM $tbl_name WHERE username='$selecteduser");
$cuser = mysql_fetch_array($userquery);
}
echo 'User:</br>';
echo '<select name="user">';
while($nt=mysql_fetch_array($result)){
echo '<option value="' . $nt['username'] . '">' . $nt['username'] . '</option>';
}
echo '</select>';
?>
<input type="submit" name="Submit" value="Select">
</br></br>
Username:
<input name="username" type="text" id="username" value="<?php echo $cuser['username']; ?>">
</br>
</form>