Page 1 of 1

why this update isnt working?

Posted: Mon Dec 15, 2003 4:30 am
by pelegk2

Code: Select all

<?php
UPDATE  table tblPrint set PrinterNum='1' where OrderNum='313.5'
?>
???

Posted: Mon Dec 15, 2003 4:32 am
by Nay
UPDATE table?

Sounds wierd to me. Try this instead:

Code: Select all

UPDATE tblPrint SET PrinterNum='1' WHERE OrderNum='313.5'
-Nay

still isnt working

Posted: Mon Dec 15, 2003 4:37 am
by pelegk2
and i dont have a clue why!

Posted: Mon Dec 15, 2003 4:38 am
by Nay
Try the query in phpmyadmin or something. See error that returns.

-Nay

Posted: Mon Dec 15, 2003 4:40 am
by m3mn0n
syntax is wrong

Code: Select all

UPDATE yourtable SET whatever='whatever' WHERE whatever='whatever'

i did so

Posted: Mon Dec 15, 2003 4:40 am
by pelegk2
there is no error just not updating :(

Posted: Mon Dec 15, 2003 4:41 am
by m3mn0n
In the query function use or die(mysql_error()).

btw see: http://www.mysql.com/doc/en/UPDATE.html

i have a strange thing

Posted: Mon Dec 15, 2003 4:59 am
by pelegk2
the problem starts with the insert
the values are inserted but
when i on the mysql do a select i got an empty line!!!!!!!!!
why can that be?
this is my insert

Code: Select all

<?php
$query2="INSERT INTO tblPrint ('OrderNum','PrinterNum','DateTime') Values('$orderN','$radio','2003-12-15 10:25:33')";
		$result2 = mysql_query ($query2) or die ($query2);
?>

Posted: Mon Dec 15, 2003 6:24 am
by Arulraj
while doing insert there is no need of giving ('OrderNum','PrinterNum','DateTime') instead give

$query2="INSERT INTO tblPrint (OrderNum,PrinterNum,DateTime) Values('$orderN','$radio','2003-12-15 10:25:33')";

This should work

Bye.

Posted: Mon Dec 15, 2003 6:47 am
by pelegk2
this is the problem :
when i do this :
$query1="select OrderNum from tblPrint where OrderNum='$orderN'";
$result1 = mysql_query ($query1) or die ($query1);
$tmpDateTimeVal=date("Y-m-d H:i:s");
if (mysql_affected_rows()){ // the order already in DB
//echo "in table";
$query2="UPDATE tblPrint set PrinterNum='$radio',DateTimeVal='$tmpDateTimeVal' where OrderNum='$orderN'";
$result2 = mysql_query ($query2) or die (mysql_error());
}else{ // need to write the order for the first time
//echo "not in table";
$query2="INSERT INTO tblPrint (OrderNum,PrinterNum,DateTimeVal) Values('$orderN','$radio','$tmpDateTimeVal')";
$result2 = mysql_query ($query2) or die (mysql_error());
}

and $orderN=313.34 and $radio=1
and then i check the mysql
i see this line :
31.34 1 2003-12-15 14:38:39
first it cuts!!!!!!! the number i dont know why!
and secondly when on mysql oi do a select on
"31.34" as show or on "313.34" i get that there are no records although i see them with my own eyes!!!!!!!!!
what is going on?
i see

Posted: Mon Dec 15, 2003 6:53 am
by Paddy
What is the exact data type of ordernum?

Posted: Mon Dec 15, 2003 7:02 am
by pelegk2
ordernum=varchar(8)

Posted: Mon Dec 15, 2003 7:02 am
by pelegk2
ordernum=varchar(8)

Posted: Mon Dec 15, 2003 7:02 am
by pelegk2
ordernum=varchar ( 8 )