Will you please read the whole thread (until the ultimate page!); not just the beginning!

the problem is in line 21 u havent declare $result...1st declare it in
mysql_query("SELECT*FROM Products='"$result"'");

although it will again give you error..because the syntax is

mysql_query(query,connection)...

in your code add $con in the connection as it hold the database connection otherwise it will create some problem later..

Can you be more specific please?

try this...

mysql_query("SELECT * FROM Products");

This might work...if it is not working then check whether there is any table or not????
And also provide us the structure of the table Products

try this...

mysql_query("SELECT * FROM Products");

This might work...if it is not working then check whether there is any table or not????
And also provide us the structure of the table Products

Provide the structure of the table Products? I´ve asked several times ´how´, but I still haven´t got a good (=understandable) reply!

Let back to your original piece of code, ie, the first one you posted. The error is at the line number '21', and it is simple MySql syntax error.

mysql_query("SELECT*FROM Products='"$result"'");

It is invalid syntax. What does '$result' mean ? Is it the variable that you want to query with ? If so, what does the '$result' refers. Field or value ? For example:

mysql_query("SELECT * FROM Products") //it fetch out all data inside the Products table
mysql_query("SELECT * FROM Products WHERE `result` = $result") //it fetch out all data from Products table where the field `result` has the value $result

But, there is one important question before fixing that line. Did you already configure or built the table with specific fields. If not, you will encounter the problem even you fixed that line.

This is my present file! What do I have to change?

<html>
<body>

<?php
$con = mysql_connect("localhost","eduardli_user","-z.x,c");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

$description = $_POST["description"];
$price = $_POST["price"];
$quantity = $_POST["quantity"];

mysql_select_db("eduardli_company", $con) or die(mysql_error());


mysql_query ("INSERT INTO Products (description, price, quantity) 
VALUES ('$description', '$price', '$quantity')") or die(mysql_error());

$latest="select * from Products order by serialno desc limit 0,1";
$result = mysql_query($latest,$con) or die(mysql_error());
$row = mysql_fetch_array($result);
{
echo $row['serialno.'] . " " . $row['description'] . " " . $row['price'] . " " . $row['quantity'];
echo "<br />";
}

mysql_close($con);
?>

</body>
</html>

I think that´s indeed the problem! But how do I get my db from phpMyAdmin to you? (Exporting?)

This post (exporting db) I posted for the first time 10 days ago and after that I asked for it several times, but I still haven´t got a decent answer!

Could you share your database table with us for reference. From the look of it I think the problem is that you are using $row when there is no such field in the database table. Perhaps you should change $row after checking your table carefully. But, it would be very easy if you could share your table with us.

PS: One advice on database naming convention: You should avoid having names like 'serial no' where you are required to use quotes. Instead of the space use underscore.

This was your question 11 days ago (share table)! I replied to it, but I haven´t got a good answer until now!

Hi

I need one favour from you can you pls provide your DB structure for the reference

I asked several times how to do this, but I haven´t got a good answer so far!

try this...

mysql_query("SELECT * FROM Products");

This might work...if it is not working then check whether there is any table or not????
And also provide us the structure of the table Products

Also this question I´ve answered! HOW?

Goto your phpmyadmin.
Select your DB.
Click export tab and save the exported file.
Attach that file Here.

NO... it's not in html form... Something is fishy around line 19 of your $result=mysql_query($q,$con). can you put a die function on line 19 and line 16 to detect the nearest place of the line where the error is coming from. then tell me the error if it's line 19 or 16

Goto your phpmyadmin.
Select your DB.
Click export tab and save the exported file.
Attach that file Here.

Ok, many thanks! I´ll do that today!

Ok, many thanks! I´ll do that today!

I´ve tried this before, but it doesn´t work (upload errors) (saved with TextWrangler)!

Goto your phpmyadmin.
Select your DB.
Click export tab and save the exported file.
Attach that file Here.

I hope it works!

Is your 'serialno' field auto increment? I have go through your products table. All rows contains value 0 for 'serialno' column.

Is your 'serialno' field auto increment? I have go through your products table. All rows contains value 0 for 'serialno' column.

Someone else gave me this! I only want to show the latest output (inserted via my form.html) on my website (www.eduardlid.com).

Someone else gave me this! I only want to show the latest output (inserted via my form.html) on my website (www.eduardlid.com).

Oh.. Ok... Your serialno field is not auto increment. It contains value 0 for all rows. So that the query doesn't return the latest update.

So do one thing. just set your 'serialno' as primary key and auto increment. It will solve your problem.
Before run the following queries remove all the rows from the table.

ALTER TABLE `products` ADD PRIMARY KEY ( `serialno` ) 

ALTER TABLE `products` CHANGE `serialno` `serialno` INT( 11 ) NOT NULL AUTO_INCREMENT

Oh.. Ok... Your serialno field is not auto increment. It contains value 0 for all rows. So that the query doesn't return the latest update.

So do one thing. just set your 'serialno' as primary key and auto increment. It will solve your problem.
Before run the following queries remove all the rows from the table.

ALTER TABLE `products` ADD PRIMARY KEY ( `serialno` ) 

ALTER TABLE `products` CHANGE `serialno` `serialno` INT( 11 ) NOT NULL AUTO_INCREMENT

Could you be more specific please, because I don´t understand it (beginner)? Not null auto_increment? Primary key?

And I want to promote myself as a web developer (by my website: www.eduardlid.com)! What would you suggest?

Could you be more specific please, because I don´t understand it (beginner)? Not null auto_increment? Primary key?

And I want to promote myself as a web developer (by my website: www.eduardlid.com)! What would you suggest?

This is my table ´Products´ now!

The products table is fine now. The following code will work fine if your form posted to this page correctly.

<html>
    <body>
     
    <?php
    $con = mysql_connect("localhost","eduardli_user","-z.x,c");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
     
    $description = $_POST["description"];
    $price = $_POST["price"];
    $quantity = $_POST["quantity"];
     
    mysql_select_db("eduardli_company", $con) or die(mysql_error());
     
     
    mysql_query ("INSERT INTO Products (description, price, quantity)
    VALUES ('$description', '$price', '$quantity')") or die(mysql_error());
     
    $latest="select * from Products order by serialno desc limit 0,1";
    $result = mysql_query($latest,$con) or die(mysql_error());
    $row = mysql_fetch_array($result);
    {
    echo $row['serialno.'] . " " . $row['description'] . " " . $row['price'] . " " . $row['quantity'];
    echo "<br />";
    }
     
    mysql_close($con);
    ?>
     
    </body>
    </html>

just change the following line

echo $row['serialno.'] . " " . $row['description'] . " " . $row['price'] . " " . $row['quantity'];

with

echo $row['serialno'] . " " . $row['description'] . " " . $row['price'] . " " . $row['quantity'];

The products table is fine now. The following code will work fine if your form posted to this page correctly.

<html>
    <body>
     
    <?php
    $con = mysql_connect("localhost","eduardli_user","-z.x,c");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
     
    $description = $_POST["description"];
    $price = $_POST["price"];
    $quantity = $_POST["quantity"];
     
    mysql_select_db("eduardli_company", $con) or die(mysql_error());
     
     
    mysql_query ("INSERT INTO Products (description, price, quantity)
    VALUES ('$description', '$price', '$quantity')") or die(mysql_error());
     
    $latest="select * from Products order by serialno desc limit 0,1";
    $result = mysql_query($latest,$con) or die(mysql_error());
    $row = mysql_fetch_array($result);
    {
    echo $row['serialno.'] . " " . $row['description'] . " " . $row['price'] . " " . $row['quantity'];
    echo "<br />";
    }
     
    mysql_close($con);
    ?>
     
    </body>
    </html>

just change the following line

echo $row['serialno.'] . " " . $row['description'] . " " . $row['price'] . " " . $row['quantity'];

with

echo $row['serialno'] . " " . $row['description'] . " " . $row['price'] . " " . $row['quantity'];

If I write now in the form.html serialno = 2 I get 21, 22?

If I write now in the form.html serialno = 2 I get 21, 22?

Sorry. I'm not able to understand your question. Come again with some more clarification.:confused:

Sorry. I'm not able to understand your question. Come again with some more clarification.:confused:

If I write (input) in my form ´seialno = 2 > The output = 22?

If I write (input) in my form ´seialno = 2 > The output = 22?

I´m still waiting for the answer!

I´m still waiting for the answer!

I'm not clear with your question. Give some more explanation

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.