View Single Post
Old 04-19-2009, 09:37 AM   #2 (permalink)
Sakakuchi
The Contributor
 
Sakakuchi's Avatar
 
Join Date: Feb 2009
Posts: 64
Thanks: 1
Sakakuchi is on a distinguished road
Default

wouw dude, hold on.

Please read once over your code:


Quote:
$fname = mysql_query("SELECT fname FROM student_reg WHERE username='$username'");
mysql_query($fname);
you are making a mysql_query -> and save the result int $fname.
then you trigger a mysql_query from the result you got from the sql query:

the code should look like that:

PHP Code:
//make a sql_query and save the result from that into $result
$resultmysql_query("SELECT `fname` FROM `student_reg` WHERE `username` = '$username'");

//next we need to fetch the data out of our result. Now it depends on what you want to do next with the data you received. Any of the below code could be right  -  depending on your what you wanna do with it

$array mysql_fetch_array($result); //would save result in a array
$objectmysql_fetch_object($result); //would save it into a object

$associativeArray mysql_fetch_assoc($result);

$field mysql_fetch_field($result); //get a single field

//next give out e.g.

echo $array['fname'];
echo 
$object->fname;

//...... 
Read that up on php.net or elsewhere ;) Then you understand best...

Your error means simply that you dont have an string available - so you cannot print/echo it
Sakakuchi is offline  
Reply With Quote