very strange problem with insert command

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

very strange problem with insert command

Post 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!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What is tblPrint's table structure?

Mac
User avatar
xisle
Forum Contributor
Posts: 249
Joined: Wed Jun 25, 2003 1:53 pm

Post by xisle »

likely an incorrect data type for you order number..
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

the order_num is varchar(8)
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

the order_num is varchar ( 8 )
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post 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??????
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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.
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post 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!
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post 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!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Have you looked at what's in the table using a GUI such as phpMyAdmin?

Mac
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post 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
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Explore that link I posted.
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post 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þ'
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

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