LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Tags used in this thread
Popular LQ Tags , , , ,

Reply
 
Thread Tools
Old 10-23-2007, 03:11 PM   #1
Scooby-Doo
LQ Newbie
 
Registered: Oct 2007
Posts: 4
Thanked: 0
Parse error: parse error, unexpected $ in /home/content/d/o/m/domain/html/addpuppy2.p


[Log in to get rid of this advertisement]
Hi I'm new to PHP and I'm building a site for my Mom. I am trying to insert data into the database but I keep getting this error.

Parse error: parse error, unexpected $ in /home/content/d/o/m/domain/html/addpuppy2.php on line 29

I think I have something wrong with my coding (wouldn't be suprised) and I would greatly appreciate if you could help me. Here's the page's coding.

PHP Code:
<?php
//DB connect info goes here.

mysql_select_db("tttbd"$con);
   
$sql="INSERT INTO addpup (name, breed_id, sex, birth_month, birth_day, birth_year, currency, price, ship_incl, ship_area, registered, vaccinated, vet_exam, health_cert, health_guar, pedigree, travel_crate, more_info)
VALUES
    ('$_POST[name]','$_POST[breed_id]','$_POST[sex]','$_POST[birth_month]','$_POST[birth_day]','$_POST[birth_year]','$_POST[currency]','$_POST[price]','$_POST[ship_incl]','$_POST[ship_area]','$_POST[registered]','$_POST[vaccinated]','$_POST[vet_exam]','$_POST[health_cert]','$_POST[health_guar]','$_POST[pedigree]','$POST[travel_crate]','$_POST[more_info]')"
;

    if (!
mysql_query($sql,$con))
    
$title "Your Puppy Added Successfully!";
  {
  die(
'<font color="ff000">Error: an error occured, please contact the website builder.</font>');
  
$title "I'm sorry and error occured";
  }
echo 
"Your Puppy has been added successfully!";
mysql_close($con)
?>
<html>
<head>
<title><?php echo $title ?></title>

</head>
<body>

<?php
    
echo $title 
?>
<br>
Please click <a href="#">HERE</a> to continue.
</body>
</html>
This is a puppy website and this page is used to upload my Mom's info.
Scooby-Doo is offline  
Tag This Post , , , ,
Reply With Quote
Old 10-24-2007, 12:19 AM   #2
derzok
Member
 
Registered: Aug 2004
Location: Ohio
Distribution: Debian, Slackware
Posts: 56
Thanked: 0
For starters, you need to put semicolons ( ; ) at the end of ALL your php commands. That includes the echo $title commands as well as your mysql_close() command
derzok is offline     Reply With Quote
Old 10-24-2007, 10:06 PM   #3
Scooby-Doo
LQ Newbie
 
Registered: Oct 2007
Posts: 4
Thanked: 0

Original Poster
Well, I'm confused, because it still doesn't work. Umm... I made the original script when I hosted my domain with hostgator and I recently switched to Godaddy and the script worked with hostgator so I copied it and edited it to make it work with the new form, but I can't get it to go through. Is there as special thing that I have to do to get it to work with Godaddy?

Last edited by Scooby-Doo; 10-24-2007 at 11:56 PM.. Reason: Updating my original post.
Scooby-Doo is offline     Reply With Quote
Old 10-25-2007, 10:41 AM   #4
Scooby-Doo
LQ Newbie
 
Registered: Oct 2007
Posts: 4
Thanked: 0

Original Poster
Here's the updated code.
PHP Code:
<?php
$con 
mysql_connect("HOST","USERNAME","PASS");
if (!
$con);
  {
  die(
'Could not connect: ' mysql_error());

mysql_select_db("tttbd"$con);
   
$sql="INSERT INTO addpup (name, breed_id, sex, birth_month, birth_day, birth_year, currency, price, ship_incl, ship_area, registered, vaccinated, vet_exam, health_cert, health_guar, pedigree, travel_crate, more_info);
VALUES
    ('$_POST[name]','$_POST[breed_id]','$_POST[sex]','$_POST[birth_month]','$_POST[birth_day]','$_POST[birth_year]','$_POST[currency]','$_POST[price]','$_POST[ship_incl]','$_POST[ship_area]','$_POST[registered]','$_POST[vaccinated]','$_POST[vet_exam]','$_POST[health_cert]','$_POST[health_guar]','$_POST[pedigree]','$POST[travel_crate]','$_POST[more_info]')"
;

    if (!
mysql_query($sql,$con));
    
$title "Your Puppy Added Successfully!";
  {
  die(
'<font color="ff000">Error: an error occured, please contact the website builder.</font>');
  
$title "I'm sorry and error occured";
  }
echo 
"Your Puppy has been added successfully!";
mysql_close($con);
?>
<html>
<head>
<title><?php echo $title?></title>

</head>
<body>

<?php
    
echo $title
?>
<br>
Please click <a href="/momsadminpage.php">HERE</a> to continue.
</body>
</html>

Last edited by Scooby-Doo; 10-25-2007 at 10:49 AM.. Reason: colorise the coding
Scooby-Doo is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What's the meaning of "PHP Parse error: parse error, unexpected $ in..." frandalla Programming 23 03-04-2009 01:34 PM
need help with "Parse error: parse error, unexpected T_STRING" coffee245 Programming 2 01-29-2007 12:53 PM
php send email parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expect jamesjoy Programming 7 12-06-2005 05:33 PM
in gcc compiler error: parse error before string constsnt cynthia_thomas Linux - Networking 1 10-20-2005 02:29 AM
PHP parse error unexpected '>' ldp Programming 2 03-04-2005 03:20 PM


All times are GMT -5. The time now is 07:58 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration