0

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

0

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>

0

HI

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

0

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.

Edited by karthik_ppts: n/a

0

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>

0

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.

Edited by kekkaishi: n/a

0

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

0

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.

0

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!

0

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>

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

1

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

Votes + Comments
correct
0

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.

0

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!

0

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

0

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.

Edited by ko ko: Wrong spelling

0

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

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?

Edited by eduardc: n/a

0

Hi

Please export your table from phpMyAdmin

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

0

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

Please, can you answer this question?

0

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

0

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!

Edited by eduardc: n/a

0

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
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.