problem using relative header(location:)

So here’s the deal. I have a SQL db that includes a home column that has the users home page. When a user logs in, I’ve been using the myaql_fetch_field to grab the column that pertains to that user and include it as part of a relative url using header(location:). My problem is, that no matter how I do it, an error spits back saying “Object of class stdClass could not be converted to string”. What am I doing wrong here?

if($count==1){
$home=mysql_fetch_field($result,3);
session_register("myusername");
session_register("mypassword");
header("Location: http://$host$uri/$home");
}
else {
header("Location:index.php");
}

mysql_fetch_field does not return a value (string). It returns an object.

See: http://us2.php.net/mysql_fetch_field

It does not return the value of the field but the properties of that field. I get data from a field you need to use mysql_query() with a SELECT statement. That will return a certain value from a particular field you choose.

Sponsor our Newsletter | Privacy Policy | Terms of Service