GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 14-Aug-2005, 11:05
quiescent quiescent is offline
New Member
 
Join Date: Aug 2005
Posts: 2
quiescent is on a distinguished road

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'


Hi, i'm new and trying to pick up PHP, was referring to this self form and i dont understand why it cant pass through since i typed word for word from the book

PHP Code:

<body>
<?php 
#assigns form values
$userName = $_POST['name'];
$userEmail = $_POST['email'];
$userMessage = $_POST ['message'];
$sent = $_POST ['sent'];

$form ="<form action=\"$_SERVER['PHP_SELF']\" method=\"post\">";
$form.="name: <input type=\"text\" name=\"name\" size=\"30\"  value=\"$userName\"> <br><br>";
$form.="email: <input type=\"text\" name=\"email\" size=\"30\"  value=\"$userEmail\"> <br><br>";
$form.="message: <input type=\"textarea\" name=\"message\" cols=\"30\" rows=\"15\" value=\"$userMessage\"> <br><br>";
$form.="<input type=\"submit\" name=\"sent\" value=\"send form\"></form>";

if {$sent) {$valid = true;
if (!userName) {$errmsg .="Enter your name:<br>"; $valid=false; }
if (!userEmail) {$errmsg .="Enter your email:<br>"; $valid=false;}
if (!userMessage){$errmsg .="Enter your message:<br>"; $valid=false;}
}

if ($valid != true) {echo ($errmsg .$form);}
else
{ $to ="my@email.com";
  $re = "Test phase";
  $msg = $userMessage;
  $headers= "From: $userName \r\n";
  if (mail ($to, $re,$msg,$headers))
  {echo ("thank you for your message, $username");
}
}

?>
</body>
</html> 

it comes out error Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in on line 12

Do advice.. thank you.
Last edited by LuciWiz : 15-Aug-2005 at 01:35. Reason: Please insert your PHP code between [php] & [/php] tags
  #2  
Old 15-Aug-2005, 06:54
quiescent quiescent is offline
New Member
 
Join Date: Aug 2005
Posts: 2
quiescent is on a distinguished road
thanks for the tip on the [php] tag. anyone can help here? :|
  #3  
Old 23-Aug-2005, 09:00
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
This ever-popular "issue" has been discussed to death here on GIDForums™.

You need to simply do one of the following:

PHP Code:

// ... curly braces
$form ="<form action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">"; 



or

PHP Code:

// ... no quotes
$form ="<form action=\"$_SERVER[PHP_SELF]\" method=\"post\">"; 


  #4  
Old 07-Sep-2005, 07:10
Richard M Richard M is offline
New Member
 
Join Date: Sep 2005
Posts: 1
Richard M is on a distinguished road
This bit is also wrong due to a curly brace:
PHP Code:

if {$sent) {$valid = true; 



Should be:
PHP Code:

if ($sent) {$valid = true; 


  #5  
Old 22-Sep-2005, 08:25
LoKo LoKo is offline
New Member
 
Join Date: Sep 2005
Posts: 2
LoKo is on a distinguished road

Re: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'


Hey I'm getting the same error with this code:
PHP Code:

$ConnError_Email="There was an error connecting with MySQL at $_SERVER['PHP_SELF']"; 


Thats's the line with the error.

and the error code is this:
Code:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in D:\WWW\~wauhost\config.php on line 92
  #6  
Old 22-Sep-2005, 08:39
LoKo LoKo is offline
New Member
 
Join Date: Sep 2005
Posts: 2
LoKo is on a distinguished road

Re: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'


NVM I figured it out... LOL
  #7  
Old 13-Oct-2005, 14:15
dave_w dave_w is offline
New Member
 
Join Date: Oct 2005
Posts: 8
dave_w is on a distinguished road

Re: Parse error: parse error, unexpected T_STRING


Can someone please help me. i am tryin to use this login system that i have found on the internet for my website but keep getting this error

Parse error: parse error, unexpected T_STRING in /home/vhosts/dwgame.wagoo2.com/main.php on line 33

The code is as below

PHP Code:

<?
/**
 * Main.php
 *
 * This is an example of the main page of a website. Here
 * users will be able to login. However, like on most sites
 * the login form doesn't just have to be on the main page,
 * but re-appear on subsequent pages, depending on whether
 * the user has logged in or not.
 *
 * Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC)
 * Last Updated: August 26, 2004
 */
include("include/session.php");
?>

<html>
<title>Jpmaster77's Login Script</title>
<body>

<table>
<tr><td>


<?
/**
 * User has already logged in, so display relavent links, including
 * a link to the admin center if the user is an administrator.
 */
if($session->logged_in){
   echo "<h1>Logged In</h1>";
   echo "Welcome <b>$session->username</b>, you are logged in. <br><br>";
       "[<a href="userinfo.php?user=$session->username">My Account</a>]   ";
       "[<a href="useredit.php">Edit Account</a>]   ";
   if($session->isAdmin()){
      echo "[<a href="admin/admin.php">Admin Center</a>]   ";
   }
   echo "[<a href="process.php">Logout</a>]";
}
else{
?>

<h1>Login</h1>
<?
/**
 * User not logged in, display the login form.
 * If user has already tried to login, but errors were
 * found, display the total number of errors.
 * If errors occurred, they will be displayed.
 */
if($form->num_errors > 0){
   echo "<font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font>";
}
?>
<form action="process.php" method="POST">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<? echo $form->value("user"); ?>"></td><td><? echo $form->error("user"); ?></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<? echo $form->value("pass"); ?>"></td><td><? echo $form->error("pass"); ?></td></tr>
<tr><td colspan="2" align="left"><input type="checkbox" name="remember" <? if($form->value("remember") != ""){ echo "checked"; } ?>>
<font size="2">Remember me next time     
<input type="hidden" name="sublogin" value="1">
<input type="submit" value="Login"></td></tr>
<tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr>
<tr><td colspan="2" align="left"><br>Not registered? <a href="register.php">Sign-Up!</a></td></tr>
</table>
</form>

<?
}

/**
 * Just a little page footer, tells how many registered members
 * there are, how many users currently logged in and viewing site,
 * and how many guests viewing site. Active users are displayed,
 * with link to their user information.
 */
echo "</td></tr><tr><td align=\"center\"><br><br>";
echo "<b>Member Total:</b> ".$database->getNumMembers()."<br>";
echo "There are $database->num_active_users registered members and ";
echo "$database->num_active_guests guests viewing the site.<br><br>";

include("include/view_active.php");

?>


</td></tr>
</table>


</body>
</html>

Thankyou to anyone who helps.
  #8  
Old 13-Nov-2005, 16:43
ubergeek ubergeek is offline
Regular Member
 
Join Date: Jan 2005
Posts: 775
ubergeek is a jewel in the roughubergeek is a jewel in the roughubergeek is a jewel in the rough

Re: Parse error: parse error, unexpected T_STRING


dave_w, if you haven't already solve your problem:

you can't do this
PHP Code:

$string = "my string with tags in it <tag prop="val">"; 


because now "val" isn't part of the string, even though you wanted it to be (as part of the echo statement). So escape, or tell PHP to ignore, the "s by using a \.
PHP Code:

$string = "my string with \"embedded\" strings."; 


if you echo the second $string, you'll get
Quote:
my string with "embedded" strings.
 
 

Recent GIDBlogOnce again, no time for hobbies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 14:30.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.