evaluv Posted October 24, 2007 Share Posted October 24, 2007 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 More sharing options...
imrie Posted October 24, 2007 Share Posted October 24, 2007 Have you defined the variables? Link to comment Share on other sites More sharing options...
evaluv Posted October 24, 2007 Author Share Posted October 24, 2007 Defined the variables?How would I do that?I was told to putin and that it would hide the error until the forms were filled out, and that then the variables would be defined. Link to comment Share on other sites More sharing options...
justsomeguy Posted October 24, 2007 Share Posted October 24, 2007 There's not a syntax error in the code you posted, post the full code. Often the actual error is on a previous line from where the error message identifies confusion. Link to comment Share on other sites More sharing options...
evaluv Posted October 24, 2007 Author Share Posted October 24, 2007 <?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 More sharing options...
justsomeguy Posted October 24, 2007 Share Posted October 24, 2007 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 More sharing options...
evaluv Posted October 24, 2007 Author Share Posted October 24, 2007 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 More sharing options...
evaluv Posted October 24, 2007 Author Share Posted October 24, 2007 never mind, Link to comment Share on other sites More sharing options...
murfitUK Posted October 24, 2007 Share Posted October 24, 2007 And missing ; after $ownerid = $_SESSION['id'] Link to comment Share on other sites More sharing options...
imrie Posted October 24, 2007 Share Posted October 24, 2007 Defined the variables?How would I do that?I was told to putin 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.