Jump to content

[SOLVED] PHP and inserting data into MySQL


pugboy

Recommended Posts

I currently have 1 table in one database. (Table named md5s)

 

For some reason, this code gives me the error "Unknown column 'wordientered' in 'field list'"

 

				mysql_connect("localhost", "md5er_admin", "*password was here*") or die(mysql_error());
			mysql_select_db("md5er_db") or die(mysql_error());
			$wordes = mysql_real_escape_string($word);
			// Insert a row of information into the table "example"
			mysql_query("INSERT INTO md5s 
			(word, md5) VALUES($wordes, $md5 ) ") 
			or die(mysql_error());  

			echo "Data Inserted!";

 

$word contains a string

$md5 contains a 32 character md5

 

Am I doing something wrong? Should I be entering the data differently?

Always quote strings in MySQL.

 

mysql_connect("localhost", "md5er_admin", "*password was here*") or die(mysql_error());
mysql_select_db("md5er_db") or die(mysql_error());
$wordes = mysql_real_escape_string($word);
// Insert a row of information into the table "example"
mysql_query("
INSERT INTO `md5s`
	(`word`, `md5`)
VALUES
	('$wordes', '$md5' )
") or die(mysql_error());  

echo "Data Inserted!";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.