Jump to content

[SOLVED] inserting data into mysql with php


big-dog1965

Recommended Posts

I have a php file that creats table and is suppost to insert some data into one of the tables it creats the table fine but doesnt insert and it doesnt give an error here is the table and the insert portion, can someone help me here

Thanks

echo '<p>Creating table login';
if(!$result = mysql_query('CREATE TABLE IF NOT Exists login ( userid int(35) NOT NULL auto_increment , user_name varchar(50) NOT NULL , user_pass varchar(255) NOT NULL , user_level varchar(50) NOT NULL , `date` varchar(20) default NULL , user_email varchar(50) NOT NULL  , user_ip varchar(50) NOT NULL , PRIMARY KEY  (userid) )')) { echo ' Error creating Table ' . mysql_error(); }

echo '<p>Inserting admin data into table Login';
mysql_query('INSERT INTO Login VALUES (
"","admin","21232f297a57a5a743894a0e4a801fc3","4","02-19-2009","[email protected]","" )');

<?php
echo '<p>Creating table login';
$result = mysql_query('CREATE TABLE IF NOT Exists login ( userid int(35) NOT NULL auto_increment , user_name varchar(50) NOT NULL , user_pass varchar(255) NOT NULL , user_level varchar(50) NOT NULL , `date` varchar(20) default NULL , user_email varchar(50) NOT NULL  , user_ip varchar(50) NOT NULL , PRIMARY KEY  (userid) )') or die(mysql_error());

echo '<p>Inserting admin data into table Login';
mysql_query("INSERT INTO Login VALUES ('','admin','21232f297a57a5a743894a0e4a801fc3','4','02-19-2009','[email protected]','' )") or die(mysql_error());

 

A: mysql uses single quotes not double quotes (your query had double quotes.)

 

B: use the die(mysql_error()) to spit out "decent" error messages upon an error (since I take it this is an install script that should be fine.).

 

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.