You didn't mention if the parse error was coming from PHP or from MySQL.
The PHP syntax looks okay to me at first glance (that is, a quick look
through indicates that there appears to be appropriate numbers of
semicolons and closing braces).

So perhaps the thing issuing the parse error is MySQL?  In that case, I'd
hazard a guess that you don't have a table named products.  Check the
spelling, capitalization, whether it's the plural "products" or the
singular "product."  What helps me say this is that the INSERT statement
above your line 52 inserts into a table called "JShistbau" and your SELECT
statement appears to pull data from a table called "products."  I'm not
saying that that's necessarily wrong, because it could very well be
perfectly valid.  But without knowing more about your database layout,
that's all I can think of.

By the way, (and it shouldn't matter...) but have you also tried removing
the space in the "end if;" (part of your larger if:-else:-endif;
statement)?  I personally don't use that alternative syntax, so I don't
know if the space matters.


At 01:22 PM 3/29/01 +1000, Petra wrote:
>I just subsribed to this list with the hope you can help me.
>I am working on this code and I get a parse error in line 52 which is ...
>I been going through it over and over and can't find a glue.
>Has anyone out there a solution for me  please?
>I am a beginner in PHP and like to hear about anything I need to know.
>Kindest Regards
>// Connect to the database server
>$dbcnx = @mysql_connect("localhost", "root", "");
>if (!$dbcnx) {
>echo( "<P>Unable to connect to the " .
>       "database server at this time.</P>" );
>//Select the products database
>if (! @mysql_select_db("JShistbau") ) {
>echo ( "<P>Unable to locate the Product " .
>       "database at this time.</P>" );
>// If a Product has been submitted,
>// add it to the database.
>if ("SUBMIT" == $submitproduct) {
>$sql = "INSERT INTO JShistbau SET " .
>               "cdescription='$productdescription', " .
>               "cdateavailable=CURDATE()";
>if (mysql_query($sql)) {
>       echo("<P>Your Product has been added.</P>");
>} else {
>       echo("<P>Error adding submitted product: " .
>mysql_error(). "</P>");
>echo("<P> Here are all the products in our database: </P>:);
>// Request the text of all the products
>$result = mysql_query(
>       "select * from products");                      !!!!!this is line 52!!!!!!
>if (!$result) {
>   echo("<P>Error performing query: " .
>         mysql_error() . "</P>");
>   exit();
>// Display the text of each product in a paragraph  
>while ( $row = mysql_fetch_array($result) ) {
>   echo("<P>" . $row["cdescription"] . "</P>");
>//When clicked, this link will load this page
>//with the product submission form displayed.
>echo("<P><AHREF='$PHP_SELF?addproduct=1'>" .
>       "Add a Product!</A></P>");
>end if;

PHP Database Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to