Hi

Pls check have put Dot after serial number in database or not. if so please remove the dot(.)

$latest="select * from Products order by serial no. desc limit 0,1";

Pls use this

$latest="select * from Products order by serial no desc limit 0,1";

Let me check how it works

Hi

Pls check have put Dot after serial number in database or not. if so please remove the dot(.)

$latest="select * from Products order by serial no. desc limit 0,1";

Pls use this

$latest="select * from Products order by serial no desc limit 0,1";

Let me check how it works

Unfornately it doesn´t work!

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'no desc limit 0,1' at line 1

<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 serial no desc limit 0,1";
$result = mysql_query($latest,$con) or die(mysql_error());
$row = mysql_fetch_array($result);
{
echo $row . " " . $row . " " . $row . " " . $row;
echo "<br />";
}

mysql_close($con);
?>

</body>
</html>

HI

Are you storing Serial no in the BD, if so please post your BD details, it will help me to rectify your issue

Just replace the following line

$latest="select * from Products order by serial no desc limit 0,1";

with

$latest="select * from Products order by `serial no` desc limit 0,1";

The space between serial and no is the problem so place the serial no within quotes as `serial no`.

Use code tags to post your codes.

Just replace the following line

$latest="select * from Products order by serial no desc limit 0,1";

with

$latest="select * from Products order by `serial no` desc limit 0,1";

The space between serial and no is the problem so place the serial no within quotes as `serial no`.

Use code tags to post your codes.

Hi,

Now it´s there 1 output, but not the latest! And there are the output of 3 fields and I want 4 (serial no, description, price, quantity)

<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 . " " . $row . " " . $row . " " . $row;
echo "<br />";
}

mysql_close($con);
?>

</body>
</html>

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.

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.

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

Well if that was the only problem I guess you do not need to share your table :) What you need to know is that the associative name should be the name of a field in the table and a field that you are selecting in the select query. ($row). If you still want to share the table then yes, export the table. That is, browse to the table and go to the export link at the top menu.

Well if that was the only problem I guess you do not need to share your table :) What you need to know is that the associative name should be the name of a field in the table and a field that you are selecting in the select query. ($row). If you still want to share the table then yes, export the table. That is, browse to the table and go to the export link at the top menu.

Thanks!

your first error is because $result isent a set var.

Still not the latest query!

<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>

Hi

$latest="select * from Products order by 'serialno' desc limit 0,1";

Pls dont use 'serialno' simply try to use serialno

Let me check the status

commented: correct +3

Replace the single quotes(') with (`) as follows

$latest="select * from Products order by `serialno` desc limit 0,1";

Or else as rpv_sen said, dont use any character as follows

$latest="select * from Products order by serialno desc limit 0,1";

please use code tags to post your codes.

I´ve made the changes above, but I still don´t get the latest output! I want what the visitor fills into my form.html of my website (www.eduardlid.com) directly as output on a computer screen!

Hi

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

Please, can someone explain exactly how I send my db from phpMyAdmin to you?
Thanks!


P. s. at this moment I have a bad connection (mobile)!

Attach the screen-shot of your PhpMyadmin or show the structure of your table. For example:

--------------------------------------------------
| id | serial_no | price | description | quantity |
--------------------------------------------------
| 1  | 1234567890 | 10$  | Loram ipsum | 3        |

P.S: Please wrap your code in code tags. Or select your codes and click the CODE button on the toolbar of the editor.

Hi

Please try the below code

<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 serial_no desc limit 0,1";
$result = mysql_query($latest,$con) or die(mysql_error());
$row = mysql_fetch_array($result);
{
echo $row['serial_no'] . " " . $row['description'] . " " . $row['price'] . " " . $row['quantity'];
echo "<br />";
}

mysql_close($con);
?>

</body>
</html>

Attach the screen-shot of your PhpMyadmin or show the structure of your table. For example:

--------------------------------------------------
| id | serial_no | price | description | quantity |
--------------------------------------------------
| 1  | 1234567890 | 10$  | Loram ipsum | 3        |

P.S: Please wrap your code in code tags. Or select your codes and click the CODE button on the toolbar of the editor.

I have a Mac (spanish keyboard!) and I don´t know how to make a screenshot! Can I also do this by exporting my db from phpMyAdmin? How?

Hi

Please export your table from phpMyAdmin

Hi

Please export your table from phpMyAdmin

How do I do that? (I´m just a beginner)

Hi

If you are using xampp server locally in your system, please check this

http://localhost/phpmyadmin

I have MAMP, but what do I have to do with the URL?

How do I do that? (I´m just a beginner)

Please, can you answer this question?

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..

Hi eduardc

sorry to say this, i dont know more about Mac.

I started this thread 13 days ago, but still the problem isn´t solved!
I can´t imagine that there isn´t anyone in this forum who really can help me!

P. s. many different answers and I´ve tried a lot of them but the problem still exist!

Rewrite your code this way

<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);


	mysql_query ("INSERT INTO Products (Description, Price, Quantity)  
	VALUES ('$description', '$price', '$quantity')");

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

	while($row = mysql_fetch_array($result))
	{
		echo $row['Description'] . " " . $row['Price'] . " " . $row['Quantity'];
		echo "<br />";
	}

	mysql_close($con);
?>

</body>
</html