开发者

Error in PHP with Mysql

Im starting to learn PHP. When I run the script it had an error that said: "Assigned Employee:resource(6) of type (mysql result)" . Please help me 开发者_JAVA百科and sorry for my bad English Here is the code:

        include_once 'rnheader.php';
        include_once 'rnfunctions.php';


</tr><tr><td><label for="AssignedEmp"> Assigned Employee:</label></td><td>';
$query = "SELECT UserName FROM employee where Classification_ClassificationID = '2'"; 
$result = queryMysql($query);

if (!queryMysql($query)) {
    echo "Query fail: $query<br />" .
    mysql_error() . "<br /><br />";
}
else
{

var_dump($result);
exit;

<select name = "UserName", "Name" size = "1">'; // or name="toinsert[]"
while ($row = mysqli_fetch_array($result)) {
  '<option value="' . htmlspecialchars($row['UserName']) . '" >' 
  . htmlspecialchars($row['UserName'])
  . '</option>';
}
}
'</select>';
?>


I isn't error. That output is produced by this line:

var_dump($result);
exit;

Since you are dumping the result of a query directly it is dumping a resource object and then you are immediately exiting the application. See after a query, you get data in a resource object, which is why we use the while loop that you have later. Remove the

exit;

And see what you get after you see

resource(6) of type (mysql result)

What is the queryMysql function that you have build? Can we see that?

Also, you have quotes here:

Classification_ClassificationID = '2'

Quotes are for strings, varchars, blobs, etc. An ID is typically an integer. Is your Classification_ClassificationID a varchar in your database or an integer. If it is an integer, take out the single quotes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜