stockton Posted September 29, 2006 Share Posted September 29, 2006 Using MSSQL database I am attempting to insert a new user into a table using the following command in PHP:-INSERT INTO Users (FirstName, LastName, Usrname, Passwrd, AccessLevel, last_login, UserID) VALUES ('Alf', 'Stockton', 'alf',0xd8cc7e40d17aaefd27cd324f7ba91079, '9', '2006/09/29 12:05:23', '0')However this fails and I am not sure why.BTW The value starting 0xd8....... is the password converted via md5()Please tell me what I got wrong. Quote Link to comment https://forums.phpfreaks.com/topic/22477-failing-to-insert-binarymd5-password/ Share on other sites More sharing options...
shivabharat Posted September 30, 2006 Share Posted September 30, 2006 What is the field type of "Passwrd" ? try using "binary" type if you havent. Quote Link to comment https://forums.phpfreaks.com/topic/22477-failing-to-insert-binarymd5-password/#findComment-101454 Share on other sites More sharing options...
MCP Posted October 1, 2006 Share Posted October 1, 2006 Why don't you just use char(32)? I can't imagine that the 16 bytes you'd "lose" per row is that critical...If you want to use a field, as the other poster said, use binary(16), or image. Quote Link to comment https://forums.phpfreaks.com/topic/22477-failing-to-insert-binarymd5-password/#findComment-102016 Share on other sites More sharing options...
straygrey Posted October 3, 2006 Share Posted October 3, 2006 I am misunderstanding the PHP Manual, where it says:-mixed *mssql_query* ( string query [, resource link_identifier [, intbatch_size]] )Returns: A MS SQL result resource on success, *TRUE* if no rows werereturned, or *FALSE* on error. and my code reads:- $passwd = ""; // for debugging only $insert = sprintf("INSERT INTO Users (FirstName, LastName, Usrname,Passwrd, AccessLevel, last_login, UserID) VALUES ('%s', '%s', '%s', '%s', '%d', '%s', '%d')", $FirstName, $Surname, $uname, $passwd,$accesslevel, $regdate, $_SESSION['UID']); $Reply = mssql_query($insert, $link); if ($Reply == FALSE) { $Message = sprintf("%s %d <br>Record not inserted. Please referproblem to Admin.", __FILE__, __LINE__); trigger_error($Message, E_USER_ERROR, $link); exit; }Maybe on an insert, no rows would be returned and therefore I possiblyshould be checking for something other than "if ($Reply == FALSE)"? Quote Link to comment https://forums.phpfreaks.com/topic/22477-failing-to-insert-binarymd5-password/#findComment-102979 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.