473,698 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parse error: syntax error, unexpected T_VARIABLE

4 New Member
Hey, I'm getting the error:

Parse error: syntax error, unexpected T_VARIABLE in /Users/Oscar/AwesomeSongz/userCake/profile.php on line 7

with this code

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     require_once("models/config.php");
  3.  
  4.     function signinTimeStamp()
  5.     {
  6.  
  7.         $sql = "SELECT LastSignIn FROM ".$db_table_prefix."Users WHERE User_ID = '"$user"'";
  8.         $result = $db->sql_query($sql);
  9.         $row = $db->sql_fetchrow($result);
  10.  
  11.         return ($row['LastSignIn']);
  12.     }
  13.  
  14.     function signupTimeStamp()
  15.     {
  16.  
  17.         $sql = "SELECT SignUpDate FROM ".$db_table_prefix."Users WHERE User_ID = '"$user"'";
  18.         $result = $db->sql_query($sql);
  19.         $row = $db->sql_fetchrow($result);
  20.  
  21.         return ($row['SignUpDate']);
  22.     }
  23.  
  24.     function groupID()
  25.     {
  26.  
  27.         $sql = "SELECT ".$db_table_prefix."Users.Group_ID, ".$db_table_prefix."Groups.* FROM ".$db_table_prefix."Users INNER JOIN ".$db_table_prefix."Groups ON ".$db_table_prefix."Users.Group_ID = ".$db_table_prefix."Groups.Group_ID WHERE User_ID  = '". $user ."'";
  28.         $result = $db->sql_query($sql);
  29.         $row = $db->sql_fetchrow($result);
  30.         $db->sql_freeresult($result);
  31.  
  32.         return($row);
  33.     } 
  34.  
  35.     $user = $_GET["user"];     
  36.  
  37.     //Prevent the user visiting the logged in page if he/she is not logged in
  38.     if(!isUserLoggedIn()) { header("Location: login.php"); die; }
  39.  
  40. ?>
  41. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  42. <html xmlns="http://www.w3.org/1999/xhtml">
  43. <head>
  44. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  45. <title>Welcome <?php echo $loggedInUser->display_username; ?></title>
  46. <link href="cakestyle.css" rel="stylesheet" type="text/css" />
  47. </head>
  48. <body>
  49. <div id="wrapper">
  50. <div id="logo"></div>
  51.  
  52. <!--
  53.  
  54.     This is an simple profile page. You can easily get access to
  55.     user properties via $loggedInUser variable which is globally accessible.
  56.  
  57. -->
  58.     <div id="regbox">
  59.  
  60.         <?php if(usernameExists($_GET["user"])) {?>
  61.         <div style="text-align:center; padding-top:15px;">
  62.  
  63.             Welcome to <strong><?php echo $user ?>'s</strong> profile.</p>
  64.  
  65.  
  66.             <p><?php echo $user ?> is a <strong><?php  $group = $loggedInUser->groupID(); echo $group['Group_Name']; ?></strong></p>
  67.  
  68.  
  69.             <p><?php echo $user ?> joined on <?php echo date("l \\t\h\e jS Y",$loggedInUser->signupTimeStamp()); ?> </p>
  70.             <p><?php echo $user ?> last logged in on <?php echo date("l \\t\h\e jS Y",$loggedInUser->signinTimeStamp()); ?> </p>
  71.  
  72.         </div>
  73.         <?php
  74.         } else {
  75.  
  76.         echo "This is not a valid username, <strong> " .$loggedInUser->display_username. " </strong></p>";
  77.  
  78.         }
  79.         ?>
  80.  
  81.  
  82.  
  83.  
  84.     </div>
  85.  
  86. </div>
  87. </body>
  88. </html>
  89. <?php include("models/clean_up.php"); ?>
  90.  
Jan 13 '10 #1
14 3596
Dormilich
8,658 Recognized Expert Moderator Expert
which is line 13?
Jan 13 '10 #2
Padfoot153
4 New Member
Sorry, Typed it wrong, should have been line 7
Jan 13 '10 #3
dgreenhouse
250 Recognized Expert Contributor
You most probably have an open parenthesis somewhere.
Like:
if $success) { // missing start paren
// do something
}

Basically, the PHP interpreter has found a variable reference when it was most likely (as mentioned) expecting a parenthesis .

Look in /profile.php which it doesn't appear you've posted above.

see: http://www.php.net/tokens for a explanation of PHP's tokens and other stuff.
Jan 13 '10 #4
Dormilich
8,658 Recognized Expert Moderator Expert
there are the concatenation operators missing around $user.
Jan 13 '10 #5
Padfoot153
4 New Member
What line is the $user on?
Jan 13 '10 #6
Dormilich
8,658 Recognized Expert Moderator Expert
this one:
Sorry, Typed it wrong, should have been line 7
Jan 13 '10 #7
Padfoot153
4 New Member
Yes, Fixed it , Thanks !
Jan 13 '10 #8
dgreenhouse
250 Recognized Expert Contributor
Line 7 should be:
Expand|Select|Wrap|Line Numbers
  1. $sql = "SELECT LastSignIn FROM ".$db_table_prefix."Users WHERE User_ID = '$user'";
  2.  
  3. Are you sure User_ID is a string?
  4.  
  5. If it's an integer, then the line should probably be:
  6. $sql = "SELECT LastSignIn FROM ".$db_table_prefix."Users WHERE User_ID = $user";
  7.  
  8. As a matter of fact, you can just eliminate the concatenation all together.
  9. i.e.
  10. $sql = "SELECT LastSignIn FROM $db_table_prefix Users WHERE User_ID = '$user'";
  11. - or if integer -
  12. $sql = "SELECT LastSignIn FROM $db_table_prefix Users WHERE User_ID = $user";
  13.  
  14. -also-
  15. $sql = sprintf("SELECT LastSignIn FROM $db_table_prefix Users WHERE User_ID = '%s'",$user);
  16. -or if intger -
  17. $sql = sprintf("SELECT LastSignIn FROM $db_table_prefix Users WHERE User_ID = %d",$user);
  18.  
Jan 13 '10 #9
dgreenhouse
250 Recognized Expert Contributor
Didn't catch the db concatenation chars...

Good catch Dormilich...
Jan 13 '10 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
19024
by: Ehartwig | last post by:
I recently created a script for user verification, solved my emailing issues, and then re-created the script in order to work well with the new PHP 5 that I installed on my server. After submitting user information into my creation script, I get the following error from the page that is suppose to insert the user data into the database, create a code, then send an email out for verification. Parse error: parse error, unexpected $end in...
2
1941
by: aamer | last post by:
can anyone please help me, im getting a dumb: Parse error: syntax error, unexpected T_VARIABLE in /home/jeddah/public_html/lomar/cart/remove.php on line 5 in the following file, <?php require_once('../include/top.php');?> <? $urlpara_local="clickmenuid=$clickmenuid&smenuid=$smenuid&pageNum_product_rec=$pageNum_product_rec&totalRows_product_rec=$totalRows_product_rec&totrec=$totrec";...
4
11621
by: bovanshi | last post by:
got this annoying error I'm completly new to php... and i have no clue what is wrong here, from what i can tell there is nothing rong with this code... but that isn't what the borwser say :P Parse error: parse error, unexpected T_VARIABLE in main.php on line 15 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title></title>
5
13161
by: Anna MZ | last post by:
I am new to php and have written the following mysql code to enter the details of a new user in the admin subdomain of my website: $sql = "INSERT INTO 'users' ('userid', 'username', 'upassword') VALUES ('$_POST', '$_POST', '$_POST') mysql_query($sql)"; When I view the code in Internet Explorer I get the following error message: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or...
1
2328
epots9
by: epots9 | last post by:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/html/xxx.php on line xxx I get that message when i try to run my script, but if i disable an if statement (code below) then my code functions correctly... if($specs == "DT") { $angle = $specs; $rating = $specs; if($angle == "00" || $angle == "30")
1
1400
by: mdouble | last post by:
I'm a complete novice with HTML and PHP. Recently I purchased an auto responder that requires me to edit a PHP file during the installation process as per directions provided in a read me file. After editing the required file (globals.php) I am directed to run the installation program on the website by using my browser. However, on doing is I am presented with an error message as follows: Parse error: parse error, unexpected...
3
6946
by: SilvaZodiac | last post by:
Hi everyone, I'm still rather new to PHP code, and I have a syntax error. I've tried several different solutions, but it won't fix. It seems to suggest that I need a new bracket somewhere in the offending line, but being amateur, I don't know where. I've tried putting one in several places, to no avail. Clearly, to solve this in a smaller period than a week I need someone with more skill to help out. Heh heh. The error is: Parse error:...
4
4406
by: needhelp08 | last post by:
I am getting the error Parse error: syntax error, unexpected T_VARIABLE on line 4 but I can't seem to find what is wrong. Could someone please help. <?php $conn = @mysql_connect("localhost", "root", "password ") $rs1 = @mysql_create_db( $_REQUEST ); $rs2 = @mysql_list_dbs( $conn ); for( $row =0; $row < mysql_num_rows( $rs2 ); $row++ ) { $list .= mysql_tablename( $rs2, $row) ." | "; }
5
10025
praclarush
by: praclarush | last post by:
I've just started php, and this is a class assignment, but my question is I’m getting this error PHP Parse error: syntax error, unexpected T_IF, expecting T_VARIABLE or '$' in C:\wamp\www\ssp\SSP04\guessingGame.php on line 42. I’ve tried to make sense of it but I’m at a lose, there error is referring to this segment of the code. else{ if(!isset($_GET)){ echo "<p>****</p>"; $guess = "****"; }//end if //declaring some...
2
3239
by: fburn | last post by:
I need some help with an error I'm getting using php 5.2.5 running on linux. I receive an error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/html/inventoryControl/supplier.php on line 26 (line number changed to match code tags) The code is as follows: // get a supplier using the supplier id
0
9156
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8860
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7712
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4614
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3038
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2323
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.