I cannot seem to figure out whats wrong with the code... every time I try and run my script on localhost I get the following error:
Parse > error: syntax error, unexpected T_VARIABLE,expecting ',' or ';' on line 35
Here is my code:
<?php
function fetch_users(){
$result = mysql_query('SELECT `user_id` AS `id`, `user_username` AS `username` FROM `users`');
$users = array();
while (($row = mysql_fetch_assoc($result)) !== false){
$users[] = $row;
}
return $users;
}
//fetch users information
function fetch_user_info($uid){
$uid = (int)$uid;
$sql = "SELECT
`user_username` AS `username`,
`user_firstname` AS `firstname`,
`user_lastname` AS `lastname`,
`user_email` AS `email`,
`user_about` AS `about`,
`user_location` AS `location`,
`user_gender` AS `gender`'
FROM `users`
WHERE `user_id` = {$uid}";
// see what the error is
echo mysql_error()
$result = mysql_query($sql);
return mysql_fetch_assoc($result);
}
?>
echo mysql_error()
– knittl Feb 13 '12 at 16:30mysql_error()
should be after the call tomysql_query()
, otherwise it's useless. That said, PHP parse errors are usually the easiest bugs to track down -- especially since the error message tells you where to look. Get into the habit of looking closely at the code around the source of an error message so that you don't have to post all of your simple typos here for everyone else to point them out. – Justin ᚅᚔᚈᚄᚒᚔ Feb 13 '12 at 16:33