Jump to content

PHP and MySQL


sylesia

Recommended Posts

Ok, so I have a query that comes up with quite an odd response when I echo it.

<?
$conn = mysql_connect("localhost", "x", "xx");
mysql_select_db("evaluation", $conn);

$request = "SELECT EvaluatorName FROM yellowcard WHERE UserName = '$userName' AND CardNumber = '$cardNumber'";
$evalUser = mysql_query($request, $conn);
echo $evalUser;
?>

Now, I have echoed $userName, $cardNumber and both show up fine.  I have also run this query in MySQL and it comes up with the correct answer.  Yet when this runs in php, I get this
Resource id #4
Now, I am not sure what the issue is, I have tested every part, even doing CardNumber = $cardNumber since it is an integer value, but that is what it keeps echoing each time I try to use it.  Am I blind and missing something obvious, or what?
Link to comment
https://forums.phpfreaks.com/topic/28448-php-and-mysql/
Share on other sites

yes, thats cos you are not calling the results

[code]
<?php
  $conn = mysql_connect("localhost", "x", "xx");
  mysql_select_db("evaluation", $conn);
 
  $request = "SELECT EvaluatorName FROM yellowcard WHERE UserName = '$userName' AND CardNumber = '$cardNumber'";
  $evalUser = mysql_query($request, $conn);

while($row = mysql_fetch_assoc($evalUser){
echo $row["fieldname"]."<br />\n";
}

?>
[/code]
Where fieldname is the name of the field in myself
Link to comment
https://forums.phpfreaks.com/topic/28448-php-and-mysql/#findComment-130175
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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