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 28-Feb-2004, 17:06
Go3Team Go3Team is offline
New Member
 
Join Date: Feb 2004
Posts: 2
Go3Team is on a distinguished road

Another "parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING" problem


Found this in a php book (so you would think it would at least work ) and when trying to execute I come up with:

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/movie/public_html/final/register.php on line 12

PHP Code:

<?

if (isset($_POST['SUBMIT'])) {

    if (strlen($_POST['name']) > 0) {
        $name = TRUE;
    } else {
        $name = FALSE;
        echo "<p>You forgot to enter your name!</p>';    
    }
    
    if (strlen($_POST['email']) > 0) {
        $email = TRUE;
    } else {
        $email = FALSE;
        echo "<p>You forgot to enter your email address!</p>';
    }
    
    if (strlen($_POST['username']) > 0) {
        $username = TRUE;
    } else {
        $username = FALSE;
        echo "<p>You forgot to enter your username!</p>';

    }
    
    if (strlen($_POST['password']) > 0) {
        if ($_POST['password1'] ==
        $_POST['password2']) {
            $password = TRUE;
        } else {
            $password = FALSE;
            echo '<p>Your password did not match the confirmed password!</p>';
            }
    } else {
            $password = FALSE;
            echo '<p>You forgot to enter your password!</p>';
    }
    
    if ($name && $email && $username && $password) {
        echo '<p>You are now registered!</p>';
    } else {
        echo '<p>Please go back and try again!</p>';
        
} else {
?>

<form action="%3C?php echo$_SERVER['PHP_SELF']; ?&gt;" method="post"> <fieldset><legend>Enter your information in the form below:</legend>

<p><b>Name:</b> <input type="text" name="name" size="20" maxlength="40" /></p>
<p><b>Email Address:</b> <input type="text" name="email" size="20" maxlength="40" /></p>
<p><b>User Name:</b> <input type="text" name="username" size="20" maxlength="40" /></p>
<p><b>Password:</b> <input type="password" name="password1" size="20" maxlength="40" /></p>
<p><b>Confirm Password:</b> <input type="password" name="password2" size="20" maxlength="40" /></p>

</fieldset>

<div align="center"><input type="submit" name="submit" value="Submit Information" /></div>

</form><!-- End of Form -->

I found in another post to add '".."' to the variable. I did, and it did not make a difference.
  #2  
Old 28-Feb-2004, 18:11
cs2 cs2 is offline
Member
 
Join Date: May 2003
Location: California
Posts: 107
cs2 will become famous soon enough
Couple of problems here...

1. The script starts by assuming short_tags are "on" (<? versus <?php), which may not be true for your server.

2. Your first three echo statements are wrong. You are opening with double-quotes and closing with single-quotes. Pick one or the other. In this case, since you don't have any parsed variables or newlines, I recommend using single-quotes (for a minor speed boost).

3. Your 'form action' is screwed up. On the line preceding, you drop out of PHP-mode (?>). You then proceed to insert PHP code into the HTML. I think What it is supposed to be saying is...
PHP Code:

<form action="<?php echo$_SERVER['PHP_SELF']; ?>" method="post"> 


not...
Code:
<form action="%3C?php echo$_SERVER['PHP_SELF']; ?&gt;" method="post">
(%3C is the hex equivalent of "<"; &gt; is the HTML entity for ">").

HTH!
__________________
The Whole Internet, LLC
Visit our Homepage, -or-
use our online CSS Editor
  #3  
Old 28-Feb-2004, 18:20
Go3Team Go3Team is offline
New Member
 
Join Date: Feb 2004
Posts: 2
Go3Team is on a distinguished road
Got all that done, seem to help a little then:

Parse error: parse error in /home/movie/public_html/final/register.php on line 59
Which is the final line


PHP Code:

<?php

if (isset($_POST['SUBMIT'])) {

    if (strlen($_POST['name']) > 0) {
        $name = TRUE;
    } else {
        $name = FALSE;
        echo '<p>You forgot to enter your name!</p>';    
    }
    
    if (strlen($_POST['email']) > 0) {
        $email = TRUE;
    } else {
        $email = FALSE;
        echo '<p>You forgot to enter your email address!</p>';
    }
    
    if (strlen($_POST['username']) > 0) {
        $username = TRUE;
    } else {
        $username = FALSE;
        echo '<p>You forgot to enter your username!</p>';

    }
    
    if (strlen($_POST['password']) > 0) {
        if ($_POST['password1'] ==
        $_POST['password2']) {
            $password = TRUE;
        } else {
            $password = FALSE;
            echo '<p>Your password did not match the confirmed password!</p>';
            }
    } else {
            $password = FALSE;
            echo '<p>You forgot to enter your password!</p>';
    }
    
    if ($name && $email && $username && $password) {
        echo '<p>You are now registered!</p>';
    } else {
        echo '<p>Please go back and try again!</p>';
        
} 
?>
<form action="<?php echo$_SERVER['PHP_SELF']; ?>" method="post"> <fieldset><legend>Enter your information in the form below:</legend>

<p><b>Name:</b> <input type="text" name="name" size="20" maxlength="40" /></p>
<p><b>Email Address:</b> <input type="text" name="email" size="20" maxlength="40" /></p>
<p><b>User Name:</b> <input type="text" name="username" size="20" maxlength="40" /></p>
<p><b>Password:</b> <input type="password" name="password1" size="20" maxlength="40" /></p>
<p><b>Confirm Password:</b> <input type="password" name="password2" size="20" maxlength="40" /></p>

</fieldset>

<div align="center"><input type="submit" name="submit" value="Submit Information" /></div>

</form><!-- End of Form -->
  #4  
Old 28-Feb-2004, 18:35
cs2 cs2 is offline
Member
 
Join Date: May 2003
Location: California
Posts: 107
cs2 will become famous soon enough
Whoops, sorry... there was one other error I missed.

This:
PHP Code:

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> 


NOT this:
PHP Code:

<form action="<?php echo$_SERVER['PHP_SELF']; ?>" method="post"> 


Notice the space after echo.
__________________
The Whole Internet, LLC
Visit our Homepage, -or-
use our online CSS Editor
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

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 09:05.


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