| | |
Parse error: parse error, unexpected T_STRING on line 40
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Aug 2008
Posts: 10
Reputation:
Solved Threads: 0
Hi, I was wondering if someone could look over my coding? x3 I'm really, really new to PHP (just learning, in fact) and a friend gave me this sample code, but it doesn't seem to work... could someone please help? Thank you so much. <3 Here is the full code:
PHP Syntax (Toggle Plain Text)
<?php include ('connect.php'); ?> <form name="form1" method="post" action="dogstore.php"> Dog's Name: <input name="dogname" type="text"> <br> Dog's Breed: <select name="dogbreed"> <option value="breed1">Breed</option> <option value="breed2">Breed</option> <option value="breed3">Breed</option> <option value="breed4">Breed</option> <option value="breed5">Breed</option> <option value="breed6">Breed</option> <option value="breed7">Breed</option> </select> <br> Dog's Gender: <select name="doggender"> <option value="Male">Male</option> <option value="Female">Female</option> </select> <br> <input type="submit" name="Submit" value="Buy Dog"> </form> <?php //trim removes the white spaces from the beginning and end of the text $dogname = trim($_POST['dogname']); $dogbreed = trim($_POST['dogbreed']); $doggender = trim($_POST['doggender']); ?> <?php //Make sure the name form is filled out. if ((isset($_POST['dogname'])) || ($_POST['dogname'] == ")) die("Oops! You forgot to fill in the name!"); ?> <?php $ownerid = $_SESSION['id'] ?> <?php if ((!isset($_POST['Buy Dog'])) { echo "Congratulations! You've purchased a dog."; } else { echo "Congratulations! You've purchased a dog.";} } ?> <?php $dog = @mysql_query("INSERT INTO dogs (ownerid, dogname, dogbreed, doggender) VALUES ('$ownerid', '$dogname', '$doggender')") or die("Error: ".mysql_error()); ?>
Last edited by Tekmaven; Aug 12th, 2008 at 5:58 am. Reason: Code tags
•
•
Join Date: Aug 2008
Posts: 48
Reputation:
Solved Threads: 4
Just wondering, where is line 40?
But some errors I spotted:
1. Your "$ownerid = $_SESSION['id']" needs a semicolon.
1. I think that your if ((!isset($_POST['Buy Dog'])) has an extra parentheses at the beginning.
3. And finally, you don't need to keep on opening and closing the php tags. Unless you have HTML or something else in between them, you should just open the tag at the beginning, and then close it only at the end.
But some errors I spotted:
1. Your "$ownerid = $_SESSION['id']" needs a semicolon.
1. I think that your if ((!isset($_POST['Buy Dog'])) has an extra parentheses at the beginning.
3. And finally, you don't need to keep on opening and closing the php tags. Unless you have HTML or something else in between them, you should just open the tag at the beginning, and then close it only at the end.
Last edited by Demiloy; Aug 12th, 2008 at 1:37 am.
•
•
Join Date: Aug 2008
Posts: 10
Reputation:
Solved Threads: 0
I tried it so that I had [*code=php] at the top and [*/code] at the bottom, and it gave me:
Parse error: parse error, unexpected T_BOOLEAN_OR in C:\Program Files\EasyPHP 2.0b1\www\dogstore.php on line 41
Argh, evil code, work already. x.X
Edit: Obvious the code was without the *
Parse error: parse error, unexpected T_BOOLEAN_OR in C:\Program Files\EasyPHP 2.0b1\www\dogstore.php on line 41
Argh, evil code, work already. x.X
Edit: Obvious the code was without the *
Last edited by wiccanwolf; Aug 12th, 2008 at 1:54 am.
•
•
Join Date: Aug 2008
Posts: 48
Reputation:
Solved Threads: 4
In any case, your if structure:
is wrong. You need to put braces around the die function. Also, you need to have two doubles quotes, i.e. || ($_POST['dogname'] == ""))
php Syntax (Toggle Plain Text)
<?php //Make sure the name form is filled out. if ((isset($_POST['dogname'])) || ($_POST['dogname'] == ")) die("Oops! You forgot to fill in the name!"); ?>
Last edited by Demiloy; Aug 12th, 2008 at 1:54 am.
![]() |
Similar Threads
- Parse error: syntax error, unexpected T_STRING (PHP)
- parse error, unexpected T_STRING in (PHP)
- Parse error: parse error, unexpected T_STRING on line 12 (PHP)
- Please Help! parse error, unexpected T_STRING (PHP)
- Parse error: parse error, unexpected T_STRING (PHP)
- PHP Parse error: parse error, unexpected T_STRING (PHP)
- Parse error: parse error, unexpected T_STRING in /home/thei2k9/public_html/includes/f (PHP)
- Need Help With Parse Error... (PHP)
Other Threads in the PHP Forum
- Previous Thread: $_POST value with <a> link click
- Next Thread: Trying to commad a script based on timing! But it doesnt work. Please help?
| Thread Tools | Search this Thread |
301 apache api array autosuggest beginner binary broken cakephp checkbox class cms code compression cron curl data database date display dropdownlist dynamic echo email eregi error execution file files folder form forms function functions google href htaccess html httppost if...loop image include insert ip javascript joomla jquery key library limit link links login mail md5 menu mlm multiple mysql mysql_real_escape_string oop paypal pdf pdfdownload php phpvotingscript problem query radio random recursion remote screen script search searchbox server session sessions sms sorting source space sql syntax system table tutorial update upload url validator variable video volume votedown web website youtube zend





