Hello,
I am using this script to read a value in a session, then I want to query the database about this value :
<?php
session_start();
$user_id = $_SESSION["user_id"] ;
echo "Your user_id is: $user_id \n" ;
$query = sprintf("SELECT * FROM `customers` WHERE id='%s' ", $user_id);
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
while ($row = mysql_fetch_assoc($result)) {
$email = $row['email'] . "\n";
echo "Your e-mail adress is : $email \n" ;
}
?>
I get this when I test the page with my browser: Your user_id is: 1430
Invalid query: Access denied for user 'nobody'@'localhost' (using password: NO) Whole query: SELECT * FROM customers
WHERE id='1430'
Thanks a lot!