Jump to content

Parse Error


evaluv
 Share

Recommended Posts

Parse error: syntax error, unexpected T_VARIABLE, expecting ']' in /usr/export/www/hosting/evaluv/buydog.php on line 53

<?php$dog = @mysql_query("INSERT INTO dogs (ownerid, dogname, dogbreed, doggender)VALUES ('$ownerid', '$dogname', '$dogbreed', '$doggender')") or die("Error:".mysql_error());?>

Line 53 is the third line in my little code-wrapped thing.How do I fix this? (Please keep it simple, I'm only 14!)

Link to comment
Share on other sites

<?phpinclude ('connect.php');?><?phperror_reporting(E_ALL ^ E_NOTICE);?><form name="buydog" method="post" action="buydog.php">Name:<input name="name" type="text"><br>Breed:<select name="breed" type="text"><option value="golden_retriever">Golden Retriever</option><option value="german_shepherd_dog">German Shepherd Dog</option><option value="bernese_mountain_dog">Bernese Mountain Dog</option><option value="american_pitbull_terrier">American Pitbull Terrier</option></select><br>Gender:<select name="gender"><option value="female">Female</option><option value="male">Male</option></select><br><input type="submit" name="Submit" value="Buy Dog"</form><?php$dogname = trim($_POST['dogname']);$dogbreed = trim($_POST['dogbreed']);$doggender = trim($_POST['doggender']);?><?php$ownerid = $_SESSION['id']?><?phpif ((!isset($_POST['{echo "Thanks for buying a dog!";}else{echo "Thanks for buying a dog!";}?><?php$dog = @mysql_query("INSERT INTO dogs (ownerid, dogname, dogbreed, doggender)VALUES ('$ownerid', '$dogname', '$dogbreed', '$doggender')") or die("Error:".mysql_error());?>

Link to comment
Share on other sites

This is the problem:if ((!isset($_POST['Also, you can remove all the excess PHP tags. You can convert this:

<?php$dogname = trim($_POST['dogname']);$dogbreed = trim($_POST['dogbreed']);$doggender = trim($_POST['doggender']);?><?php$ownerid = $_SESSION['id']?><?phpif ((!isset($_POST['{echo "Thanks for buying a dog!";}else{echo "Thanks for buying a dog!";}?><?php$dog = @mysql_query("INSERT INTO dogs (ownerid, dogname, dogbreed, doggender)VALUES ('$ownerid', '$dogname', '$dogbreed', '$doggender')") or die("Error:".mysql_error());?>

to this:

<?php$dogname = trim($_POST['dogname']);$dogbreed = trim($_POST['dogbreed']);$doggender = trim($_POST['doggender']);$ownerid = $_SESSION['id']if ((!isset($_POST['{echo "Thanks for buying a dog!";}else{echo "Thanks for buying a dog!";}$dog = @mysql_query("INSERT INTO dogs (ownerid, dogname, dogbreed, doggender)VALUES ('$ownerid', '$dogname', '$dogbreed', '$doggender')") or die("Error:".mysql_error());?>

it still has the same syntax error though. Also, your submit button tag is missing a closing bracket.

Link to comment
Share on other sites

This is the problem:if ((!isset($_POST['Also, you can remove all the excess PHP tags. You can convert this:
<?php$dogname = trim($_POST['dogname']);$dogbreed = trim($_POST['dogbreed']);$doggender = trim($_POST['doggender']);?><?php$ownerid = $_SESSION['id']?><?phpif ((!isset($_POST['{echo "Thanks for buying a dog!";}else{echo "Thanks for buying a dog!";}?><?php$dog = @mysql_query("INSERT INTO dogs (ownerid, dogname, dogbreed, doggender)VALUES ('$ownerid', '$dogname', '$dogbreed', '$doggender')") or die("Error:".mysql_error());?>

to this:

<?php$dogname = trim($_POST['dogname']);$dogbreed = trim($_POST['dogbreed']);$doggender = trim($_POST['doggender']);$ownerid = $_SESSION['id']if ((!isset($_POST['{echo "Thanks for buying a dog!";}else{echo "Thanks for buying a dog!";}$dog = @mysql_query("INSERT INTO dogs (ownerid, dogname, dogbreed, doggender)VALUES ('$ownerid', '$dogname', '$dogbreed', '$doggender')") or die("Error:".mysql_error());?>

it still has the same syntax error though. Also, your submit button tag is missing a closing bracket.

Thanks :)
Link to comment
Share on other sites

Defined the variables?How would I do that?I was told to puttut9.pngin and that it would hide the error until the forms were filled out, and that then the variables would be defined.
This is defining variables:
$dogname = trim($_POST['dogname']);$dogbreed = trim($_POST['dogbreed']);$doggender = trim($_POST['doggender']);

You had defined them.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...