Jump to content

Parse Error


evaluv

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...