PHP: unexpected T_VARIABLE

Associate
Joined
18 Oct 2002
Posts
858
Location
Cheshire
I get the following error message....
Code:
[b]Parse error[/b]: syntax error, unexpected T_VARIABLE, expecting '(' in .....

oky, heres the first 10 lines....

Code:
<?php require_once('Connections/pink_db.php'); ?>
<?php
if $Auth=="y" { $Auth = "Y"; }
if $Auth=="" { $Auth = "N"; }
if $Auth=="n" { $Auth = "N"; }
if $Auth!=="N" {
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
if($Name=="" || $address1=="" || $address2=="" || $town=="" || $county=="" || $postcode=="" || $phone=="" || $DOB=="" || $bid=="" || $Auth=="" || $time_stamp=="" ){

I just can't spot it....

can anyone see it?

Thanks

:edit
oky, I added the brackets.....

now getting the error

Code:
[b]Parse error[/b]: syntax error, unexpected '}', expecting ',' or ';' in
 
Last edited:
You need to have the condition for 'if' declarations inside parentheses :

like :
if ($Auth=="y") { $Auth = "Y"; }

not :
if $Auth=="y" { $Auth = "Y"; }
 
Code:
<?php
if ( $Auth == 'y' )
    $Auth = "Y";
if ( empty($Auth) || $auth == 'n' ) 
    $Auth = "N";

if ( strtolower($Auth) != 'n' ) {
    $errors = 0;
    $error = "The following errors occured while processing your form input.<ul>";
    if(
        empty($Name) || 
        empty($address1) || 
        empty($address2) || 
        empty($town) ||
        empty($county) || 
        empty($postcode) || 
        empty($phone) || 
        empty($DOB) || 
        empty($bid) || 
        empty($Auth) || 
        empty($time_stamp) 
    ) {

This is still a really stupid way of doing things, though. Plus you appear to be relying on register_globals which is even stupider.

Try:

Code:
$auth = strtolower(trim($_POST['auth']));

$required_fields = array('name', 'address1', 'address2', 'town', 'county', 'postcode', 'phone', 'dob', 'bid', 'auth', 'time_stamp');

if ( $auth != 'n' ) {
    $errors = 0;
    $error = 'You have an error blah blah';

    foreach ( $required_fields as $field ) {
        if ( empty($_POST[$field]) )
            $errors++;
            $error .= 'blah blah';
    }
}
 
Erm, I'm using register globals because the info is required by multiple pages and it's a pain in the arse to use URLENCODE and URLDECODE all the time.... not to mention messy.....

Sorted it now.... apart from an unexpected T_STRING error.....
 
oky, perhaps I lost the plot... I need to go home n sleep.... but this charity website is p***in me off....

Code:
[b]Parse error[/b]: syntax error, unexpected T_STRING, expecting ',' or ';' in ...... on line [b]35[/b]
lines 31 - 39 are....

Code:
31	mysql_select_db($database_pink_db, $pink_db);
32	$query="insert into Bids (name,address1,address2,town,county,post_code,Phone,email,DOB,bid,Auth,time_stamp) values ('".$name."','".$address1."','".$address2."','".$town."','".$county."','".$postcode."','".$phone."','".$email."','".$DOB."','".$bid."','".$Auth."','".$time_stamp."')";
33	mysql_query($query) or die(mysql_error());
34	}
35	echo "Your entry has been accepted. <br>Please click <a href="index.php">HERE</a> to go back to the main page.";
36	}
37	else
38	{ echo "You did not type a Y in the box to agree to bid. Please use your browsers back button."; }
39	?>

I got the matrix effect infront of my eyes..... :(
 
Please fix your coding style, this is a real pain to read. Indent code blocks, line braces up properly, etc. You also seem to have a morbid fear of whitespace which doesn't help matters.

Code:
		mysql_select_db($database_pink_db, $pink_db);
		mysql_query("
		INSERT INTO Bids
		(name, address1, address2, town, county, post_code, Phone, email, DOB, bid, Auth, time_stamp)
		VALUES ('$name', '$address1', '$address2', '$town', '$county', '$postcode', '$phone', '$email', '$DOB', '$bid', '$Auth', '$time_stamp')
		") or die(mysql_error());
	}
	echo 'Your entry has been accepted. <br>Please click <a href="index.php">HERE</a> to go back to the main page.';
} else { 
	echo "You did not type a Y in the box to agree to bid. Please use your browsers back button.";
}

(The problem was the unescaped double-quotes in the string.)

Also, I hope you're escaping that user input.
 
doh, arse....
it's coz I added that a href....

ok, pinkscooter is now known as a swearword....

www.pinkscooter.co.uk

I wonder if OCUK will be sending these forums pink for the day? ;)

:edit
It's friday, stop picking on me code... I do wonderfull coding on a monday
 
Last edited:
Back
Top Bottom