Jump to content

[SOLVED] Error


EagleAmerican

Recommended Posts

Hi and much thanks to whomever can help me with my problem. I've tried it for hours to get it myself but just can't. So here goes:

 

Error Message when trying to go to page:

 

Parse error: parse error, unexpected T_VARIABLE, expecting ',' or ';' in /home/www/blah.blah/add_parasite.php on line 66

 

PHP lines causing problem:

 

 if (isset($_POST['parasitename'])) {
   $parasitename = $_POST['parasitename'];
   $parasitefrom = $_POST['parasitefrom'];
   $parasitegenre = $_POST['parasitegenre'];
   $parasitedescription = $_POST['parasitedescription'];
   $parasitetechinfo = $_POST['parasitetechinfo'];
   $sql = "INSERT INTO parasite SET
       parasitename='$parasitename',
       parasitefrom='$parasitefrom',
       parasitegenre='$parasitegenre',
       parasitedescription='$parasitedescription',
       parasitetechinfo='$parasitetechinfo',
       parasitedateadded=CURDATE()";
   if (@mysql_query($sql)) {
     echo '<p>The parasite '$parasitename' has been added.</p>';
   } else {
     echo '<p>Error adding submitted parasite: ' .
         mysql_error() . '</p>';
   }
}

 

Thanks,

Adam

Link to comment
Share on other sites

You were using single quotes inside of single quotes. Next time please point out what line is 66.

 

<?php
if (isset($_POST['parasitename'])) {
   $parasitename = $_POST['parasitename'];
   $parasitefrom = $_POST['parasitefrom'];
   $parasitegenre = $_POST['parasitegenre'];
   $parasitedescription = $_POST['parasitedescription'];
   $parasitetechinfo = $_POST['parasitetechinfo'];
   $sql = "INSERT INTO parasite SET
       parasitename='$parasitename',
       parasitefrom='$parasitefrom',
       parasitegenre='$parasitegenre',
       parasitedescription='$parasitedescription',
       parasitetechinfo='$parasitetechinfo',
       parasitedateadded=CURDATE()";
   if (@mysql_query($sql)) {
     echo "<p>The parasite '$parasitename' has been added.</p>";
   } else {
     echo '<p>Error adding submitted parasite: ' .
         mysql_error() . '</p>';
   }
}

Link to comment
Share on other sites

Hi and thanks so much for your help. That part works now. However now I can't get it to list all of the parasites in the database. :( The message I get is:

 

Parasite list:

 

Error performing query1:

 

Here's the coding where the problem occurs:

 

echo '<p>Parasite list:</p>';

$name = @mysql_query('SELECT parasitename FROM parasite');
if (!$result) {
exit('<p>Error performing query1: ' . mysql_error() . '</p>');
}
$from = @mysql_query('SELECT parasitefrom FROM parasite');
if (!$result) {
exit('<p>Error performing query2: ' . mysql_error() . '</p>');
}
$genre = @mysql_query('SELECT parasitegenre FROM parasite');
if (!$result) {
exit('<p>Error performing query3: ' . mysql_error() . '</p>');
}
$description = @mysql_query('SELECT parasitedescription FROM parasite');
if (!$result) {
exit('<p>Error performing query4: ' . mysql_error() . '</p>');
}
$techinfo = @mysql_query('SELECT parasitetechinfo FROM parasite');
if (!$result) {
exit('<p>Error performing query5: ' . mysql_error() . '</p>');
}

 

And the MySQL is structured like this:

 

 Full Texts  	 id  	 parasitename  	 parasitefrom  	 parasitegenre  	 parasitedescription  	 parasitetechinfo  	 parasiteadddate
Edit 	Delete 	1 	Test.Blah 	Unknown 	Unknown 	This is a Test Parasite. 	Test Parasite. 	0000-00-00

Link to comment
Share on other sites

Your result variables aren't consistant.

 

<?php
$name = @mysql_query('SELECT parasitename FROM parasite');
if (!$result) {
exit('<p>Error performing query1: ' . mysql_error() . '</p>');
}

 

Should be:

<?php
$name = @mysql_query('SELECT parasitename FROM parasite');
if (!$name) {
exit('<p>Error performing query1: ' . mysql_error() . '</p>');
}

 

Notice how the var used in the IF statement is now the same as the one used in mysql_query? That's how it's suppose to be.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.