TLN_CANADA
asked on
Printing PHP value on page
Hi all,
This is simple question but I think using the PHPfox it might be causing some issues.
I am using this SQL statement to get a value (it will be either no value or 1 value) from the DB:
I want to print this on a form on the page. How do I do this?
Thanks,
D
This is simple question but I think using the PHPfox it might be causing some issues.
I am using this SQL statement to get a value (it will be either no value or 1 value) from the DB:
$query = mysql_query("SELECT question FROM cometchat_question WHERE userid = '$username' ");
I want to print this on a form on the page. How do I do this?
Thanks,
D
$query in that statement will only be a resource identifier, not the data you are looking for. You still need to use mysql_fetch_array() or one of the other methods to get the actual data, even if it is only one item. http://us2.php.net/manual/en/function.mysql-fetch-array.php
ASKER
Here is what I have but it's giving an error:
Parse error: syntax error, unexpected T_ECHO in /home/clear555/public_html /dyadmenu. php on line 48
$query = mysql_query("SELECT question FROM cometchat_question WHERE userid = '$username' ");
$row = mysql_fetch_array($query)
echo $row ;
Parse error: syntax error, unexpected T_ECHO in /home/clear555/public_html
You need a semi-colon ';' at the end of the second line. Like...
$row = mysql_fetch_array($query);
ASKER
Thanks, it's strange when I run the sql statement in the db it returns the result correct but when I print the array like this on the page it comes up blank. The username prints correct so it is connecting to the DB.
It would be a varchar format the question field that I am trying to fetch.
In this case the correct result from the db would be "Hello World"
It would be a varchar format the question field that I am trying to fetch.
In this case the correct result from the db would be "Hello World"
$username = Phpfox::getUserBy('user_id');
echo $username ;
// Check for question
$query = mysql_query("SELECT question FROM cometchat_question WHERE userid = '$username' ");
$row = mysql_fetch_array($query) ;
echo $row ;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.