Page 1 of 2

very strange problem with insert command

Posted: Mon Dec 15, 2003 8:25 am
by pelegk2
i am working php+mySql
i am trying to do a simple insert command :
$query2="INSERT INTO tblPrint (OrderNum,PrinterNum,DateTimeVal) Values('$order_num','$radio','$tmpDateTimeVal')";

when i havethis values :
$order_num=313.517;
$radio=1;
$tmpDateTimeVal=date("Y-m-d H:i:s");

when i check the mysql i see that the order_num value
is for some reason 3.517 ?!?!?!?!?!
why is that?any idea????
the more intresting if i do the same line with the same values it tels me its a duplicate key!!!!!!
but if i chek it from php with a select it tells m that that vakue dosent exist!!!!!!!!
help dont know what else to do!

Posted: Mon Dec 15, 2003 8:37 am
by twigletmac
What is tblPrint's table structure?

Mac

Posted: Mon Dec 15, 2003 10:18 am
by xisle
likely an incorrect data type for you order number..

Posted: Mon Dec 15, 2003 11:02 am
by pelegk2
the order_num is varchar(8)

Posted: Mon Dec 15, 2003 11:03 am
by pelegk2
the order_num is varchar ( 8 )

Posted: Tue Dec 16, 2003 12:44 am
by pelegk2
i changed the varchar to size 11
it at last put the data but when i do :
select * from tblprint where ordernum like '%313.1729%'

bu i get 0 records!!!why??????

Posted: Tue Dec 16, 2003 1:27 am
by infolock
check to make sure you have a record in your table that has a value like that first of all..

in other words, it will only display values that have 313.1729 in the actual value...

so, if you have a number like 245313.172924 it will return a row.. otherwise, it returns no rows.. also make sure you are in the correct table.

other than t hat, the syntax you are using is fine as it should return a row if there is an order number that actually fits that description you are giving it.

Posted: Tue Dec 16, 2003 1:38 am
by pelegk2
yes but if i do
245313.172924
i will get the number cut off as before!!!!
the thing is i have used the function called parse_str()
and i get the values there
the most strange thing is when i write down manually the value in the insert command it works just find!

Posted: Tue Dec 16, 2003 2:08 am
by m3mn0n

Posted: Tue Dec 16, 2003 2:31 am
by pelegk2
but i want to understand why it isnt woking for me!
the programmer before me did it and it worked fine!
i dont find any diffrence!

Posted: Tue Dec 16, 2003 2:36 am
by twigletmac
Have you looked at what's in the table using a GUI such as phpMyAdmin?

Mac

Posted: Tue Dec 16, 2003 3:08 am
by pelegk2
first i work with hebrew>!
maybe i need to do a codepage set first!
then how do i do it in php?
second when i did copy of paste from the table i got this :
'þ172þ.þ313þ'
the strabge leteers i see as spaces in mysql
and when i do a select on 'þ172þ.þ313þ'
it works but i dont understand why?
thanks again
peleg

Posted: Tue Dec 16, 2003 3:14 am
by m3mn0n
Explore that link I posted.

Posted: Tue Dec 16, 2003 3:39 am
by pelegk2
it has no conection with the link u posted!!!
the problem is tht i reive data from ERP
and knowwhen i check it the order_num length is 1 instead of 8
while on screen i dont see the rest 3 chars!!!!!!!!!
execlly what ishowed u in 'þ172þ.þ313þ'

Posted: Tue Dec 16, 2003 3:45 am
by twigletmac
Additional characters are getting inserted into the database that are causing it to go wrong, so where does $order_num come from.

Mac