LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Parse error: parse error, unexpected $ in /home/content/d/o/m/domain/html/addpuppy2.p (https://www.linuxquestions.org/questions/programming-9/parse-error-parse-error-unexpected-%24-in-home-content-d-o-m-domain-html-addpuppy2-p-593982/)

Scooby-Doo 10-23-2007 02:11 PM

Parse error: parse error, unexpected $ in /home/content/d/o/m/domain/html/addpuppy2.p
 
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.

derzok 10-23-2007 11:19 PM

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

Scooby-Doo 10-24-2007 09:06 PM

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?

Scooby-Doo 10-25-2007 09:41 AM

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>



All times are GMT -5. The time now is 01:53 AM.