silverglade Posted January 12, 2010 Share Posted January 12, 2010 hi, my script is supposed to insert the word "password" as an MD5'ed string into my table. but it doesnt . here is my code, any help GREATLY appreciated as ive been working on this for a few hours. LOL. thank you. derek <?php include("connect1.php"); $1a = "password"; md5($1a); mysql_query("INSERT INTO members (Email, Password) VALUES ('user@yahoo.com','$1a')"); if(mysql_error()) { echo "Error: " . mysql_error(); } else { echo "Worked fine"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/188191-trying-to-insert-a-md5ed-variable-into-a-mysql-table-but-cant/ Share on other sites More sharing options...
dgoosens Posted January 12, 2010 Share Posted January 12, 2010 md5($1a); is the error... this is not OOPHP but procedural... thus, you should write it like this $1a = md5($1a); Quote Link to comment https://forums.phpfreaks.com/topic/188191-trying-to-insert-a-md5ed-variable-into-a-mysql-table-but-cant/#findComment-993520 Share on other sites More sharing options...
silverglade Posted January 12, 2010 Author Share Posted January 12, 2010 great thank you very much. i changed it and the code is still not updating the table and not showing the "worked" message. here is the code im using now. any more help greatly appreciated thank you. <?php include("connect1.php"); $1a = "password"; $1a = md5($1a); mysql_query("INSERT INTO members (Email, Password) VALUES ('user@yahoo.com','$1a')"); if(mysql_error()) { echo "Error: " . mysql_error(); } else { echo "Worked fine"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/188191-trying-to-insert-a-md5ed-variable-into-a-mysql-table-but-cant/#findComment-993527 Share on other sites More sharing options...
dgoosens Posted January 12, 2010 Share Posted January 12, 2010 well, here again... you should use a variable to get the response you're getting from mysql_query do go through the doc and the examples here: http://uk.php.net/manual/en/function.mysql-query.php Quote Link to comment https://forums.phpfreaks.com/topic/188191-trying-to-insert-a-md5ed-variable-into-a-mysql-table-but-cant/#findComment-993532 Share on other sites More sharing options...
Zane Posted January 12, 2010 Share Posted January 12, 2010 variable names can't start with a number. Quote Link to comment https://forums.phpfreaks.com/topic/188191-trying-to-insert-a-md5ed-variable-into-a-mysql-table-but-cant/#findComment-993539 Share on other sites More sharing options...
dgoosens Posted January 12, 2010 Share Posted January 12, 2010 variable names can't start with a number. is it "1" (one) or "l" (L) ?? in code it is not very clear $1a; // one $la; // L Quote Link to comment https://forums.phpfreaks.com/topic/188191-trying-to-insert-a-md5ed-variable-into-a-mysql-table-but-cant/#findComment-993542 Share on other sites More sharing options...
silverglade Posted January 12, 2010 Author Share Posted January 12, 2010 thank you both SO MUCH!! i FINALLY got it to work! AWESOME HAHAHAHA. thank you very much. derek :D :D Quote Link to comment https://forums.phpfreaks.com/topic/188191-trying-to-insert-a-md5ed-variable-into-a-mysql-table-but-cant/#findComment-993543 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.