I have the following code, written in php 5, to extract an ID from the User table.
$userid="SELECT userid FROM user WHERE email='$email'";
$userid_result = mysql_query($userid) or die(mysql_error());
$userid_result_value = mysql_fetch_object($userid_result);
I then try and store this result into a session variable.
$_SESSION['uid']=$userid_result_value;
I then try and call this session variable else where in my website. Each, and everytime that I do, I get the error "Catchable fatal error: Object of class stdClass could not be converted to string in C:\Test\reg_form_step2.php on line 41". The code at line 41 is:
<?php echo $_SESSION['uid']; ?>
I've tried changing the 'userid' to 'firstname' from the SELECT statement, as I thought it might be something to do with the the fact that the ID is automactically generated. I used the LAST_INSERT_ID() command to store the ID into another table, I get the same error when I try to call the variable held in this field too.
What I really want to do is insert the user ID from the user table into another table along with another user ID as follows:
$insert_user_img = "INSERT INTO img(imgID,user_image) VALUES (null,'$u_img')";
mysql_query($insert_user_img) or die (mysql_error());
$img_insert = "INSERT INTO user_image(UserID,imgID)VALUES('$_SESSION['uid']', LAST_INSERT_ID())";
$img_insert_result = mysql_query($img_insert) or die (mysql_error());
But the way things are going, that's just a distant dream.
It'd be fair to say that this problem is driving me nuts, your help would be greatly appreciated.
Thank you in advance. 🙂