0

In my user registration page I insert the form data into the table with this code

$msquerys="
           insert into userdata (account,password,rank,socno,email,block) 
           VALUES ('".$account."','".$pass."','".$rank."',  '123123-1231231','".$email."','".$blockdata."')";

$msresultss=odbc_exec($conn2,$msquerys) or die('<div align="center">

Sadly I need to enter SOCNO as 123123-1231231 with that hyphen, however when it inserts this value -1108108 instead. It's like PHP is seeing it as a subtraction and inserting it like that.

bummi
  • 27,123
  • 14
  • 62
  • 101
  • I would suggest that you use prepared statements, take a look at: http://stackoverflow.com/questions/5756369/odbc-prepared-statements-in-php – NullBy7e Oct 27 '14 at 12:30
  • That shouldn't be the case, cause `'123123-1231231'` will be considered as string literal. – Rahul Oct 27 '14 at 12:34

1 Answers1

0

You can try using prepared statements:

http://php.net/manual/en/function.odbc-prepare.php

$msquerys=odbc_prepare($conn2, "insert into userdata (account,password,rank,socno,email,block) VALUES (?, ?, ?, ?, ?, ?)");
$msresultss=odbc_execute($msquerys, array($account, $pass, $rank, "123123-1231231", $email, $blockdata)) or die('<div align="center">
<p align="center"><strong>#################### Something went wrong, Please seek help! ####################</strong></p> </div>  ');
NullBy7e
  • 536
  • 9
  • 23
  • I was in the middle of reading your comment and I started to give it a go then I saw this. Thank you very much for your help sir! – Chris Tindal Oct 27 '14 at 12:47