I'm a new comer to Linux/Ubuntu so if I make any silly mistake please forgive me.
My code works fine in XP but not in Ubuntu 11.04 (Same PHP/MySQL version)<?php
if (!isset($_SESSION['uid'])) {
header('Location:index.php');
exit;
} else {
if (file_exists("profile_pic/".$_SESSION['uid'].".jpg")) {
echo '<a href="'.$SitePath.'profile.php?id='.$_SESSION['uid'].'"><img src="'.$SitePath.'profile_pic/'.$_SESSION['uid'].'.jpg" alt="'.$_SESSION['name'].'" title="Me" border="0"/></a>';
} else {
echo '<a href="'.$SitePath.'profile.php?id='.$_SESSION['uid'].'"><img src="'.$SitePath.'profile_pic/nopic.jpg" alt="'.$_SESSION['name'].'" title="Me" border="0" /></a>';
}
?>
If a file exists with nam开发者_开发知识库e of $_SESSION['uid'].".jpg"
then show it, else show an default image.
The error I'm getting
Catchable fatal error: Object of class mysqli_stmt could not be converted to string
You're not showing any database operations, but most likely you've got something like:
$_SESSION['uid'] = mysqli_query("SELECT uid FROM ...");
wherever you're initializing your session data. This is incorrect. The query functions return a statement handle, from which you can fetch the data. In pseudo-code, it'd be:
$result = mysqli_query(...);
$row = $result->fetch();
$_SESSION['uid'] = $row['uid'];
try to print_r($_SESSION['uid']) that will give you a hint what is it, most likely as Marc B said
精彩评论