There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen blue screen blue screen of death boot bsod computer connection crash css dell display driver drivers email error explorer firefox firefox 3 hard drive internet internet explorer itunes laptop lcd malware monitor network networking outlook outlook 2003 outlook express printer problem problems ram router security slow software sound sprtcmd.exe trojan usb video virus vista windows windows xp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Getting invalid $, and there is no $


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
lightnb's Avatar
Senior Member with 780 posts.
 
Join Date: Jun 2002
Location: Seattle
Experience: Advanced
08-May-2006, 11:06 PM #1
Getting invalid $, and there is no $
I have this code:


PHP Code:
<?php

// function to output form and hold previously entered values.

function user_form() {
    
    
//output the form HTML.
    
echo '<p>Please fill in at least two fields.</p>';
    echo 
'<form action="'.htmlspecialchars($_SERVER['PHP_SELF']).'" method="post">';
    echo 
'<table border="0" cellspacing="4" cellpadding="0">';
    echo 
'<tr><td>Vertical Distance:</td><td><input type="text" name="VD" value="'.htmlspecialchars($_POST['VD']).'"></td></tr>';
    echo 
'<tr><td>Horizontal Distance:</td><td><input type="text" name="HD" value="'.htmlspecialchars($_POST['HD']).'"></td></tr>';
    echo 
'<tr><td>Throw Distance:</td><td><input type="text" name="TD" value="'.htmlspecialchars($_POST['TD']).'"></td></tr>';
    echo 
'<tr><td colspan="2"><input type="submit" value="submit" name="submit"></td></tr>';
    echo 
'</table>';
    echo 
'</form>';

}


// has the form been submitted?
if (isset($_POST['submit'])) {$error_str '';
                                if( isset(
$_POST['VD'])) { if(!is_numeric($_POST['VD'])){$error_str .= '<li>VD must be a number</li>'; }
                                if( isset(
$_POST['HD']) ) { if( !is_numeric($_POST['HD'])){$error_str .= '<li>HD must be a number</li>'; }
                                if( isset(
$_POST['TD']) ) { if( !is_numeric($_POST['TD'])){$error_str .= '<li>TD must be a number</li>'; }
                                
                                 if (!empty(
$error_str)) {echo '<ul>'.$error_str.'</ul>';  user_form(); exit; }
                                 else {echo
'Success!!';}                
                                
                                } else {
user_form(); }
?>

And I'm getting this errer:

Code:
Parse error: parse error, unexpected $ in /home/.sites/22/site13/web/livexchange/tools/pc2.php on line 32
There is no dollar sign on line 32!

Any ideas?
CyberGeek's Avatar
Member with 47 posts.
 
Join Date: Mar 2006
Location: London, Ontario
Experience: Advanced Developer
10-May-2006, 12:43 AM #2
Hehehe. Wanna know something else, there is no line 32.

So, what your actual error is, really on a line before the imaginary line 32.
Rockn's Avatar
Computer Specs
Distinguished Member with 17,888 posts.
 
Join Date: Jul 2001
Location: Mexico of the North, MN
Experience: Disenfranchised American Male
10-May-2006, 09:53 AM #3
I pasted the code into my editor and the page displays the same error. I thought it might have to do with some of your nested if statements and bracketing. Ask brandon, I am sure he can figure it out in a second or two.
brendandonhu's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
10-May-2006, 10:18 AM #4
I don't think its doing what you want since the script gives an error unless all 3 fields are filled in, but this will fix the parse error you're getting.

PHP Code:
<?php

// function to output form and hold previously entered values.

function user_form() {
    
    
//output the form HTML.
    
echo '<p>Please fill in at least two fields.</p>';
    echo 
'<form action="'.htmlspecialchars($_SERVER['PHP_SELF']).'" method="post">';
    echo 
'<table border="0" cellspacing="4" cellpadding="0">';
    echo 
'<tr><td>Vertical Distance:</td><td><input type="text" name="VD" value="'.htmlspecialchars($_POST['VD']).'"></td></tr>';
    echo 
'<tr><td>Horizontal Distance:</td><td><input type="text" name="HD" value="'.htmlspecialchars($_POST['HD']).'"></td></tr>';
    echo 
'<tr><td>Throw Distance:</td><td><input type="text" name="TD" value="'.htmlspecialchars($_POST['TD']).'"></td></tr>';
    echo 
'<tr><td colspan="2"><input type="submit" value="submit" name="submit"></td></tr>';
    echo 
'</table>';
    echo 
'</form>';

}


// has the form been submitted?
if (isset($_POST['submit'])) {$error_str '';
                                if( isset(
$_POST['VD'])) { if(!is_numeric($_POST['VD'])){$error_str .= '<li>VD must be a number</li>'; } }
                                if( isset(
$_POST['HD']) ) { if( !is_numeric($_POST['HD'])){$error_str .= '<li>HD must be a number</li>'; } }
                                if( isset(
$_POST['TD']) ) { if( !is_numeric($_POST['TD'])){$error_str .= '<li>TD must be a number</li>'; } }
                                
                                 if (!empty(
$error_str)) {echo '<ul>'.$error_str.'</ul>';  user_form(); exit; }
                                 else {echo
'Success!!';}                
                                
                                } else {
user_form(); }
?>
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 01:02 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.