954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

help with my insert query

hello there,
this is my simple php code which inserts a row into the db.
the problem is that it doesnt work 'nothing happens no row is being insert and i dont get any error.
I have no idea whats wrong.
hope to get any solution.
thanks.


db structure:
Id int(11) auto_increment
Mail varchar(256) utf8_general_ci
Pass varchar(256) utf8_general_ci
Name varchar(256) utf8_general_ci
LName varchar(256) utf8_general_ci
Details text utf8_general_ci

$mysql_link=mysql_connect('localhost','root','123456') or die("ERROR: cannot connect to MySQL server.");
  echo "connected successfully to MySQL server.";
mysql_select_db('gwars',$mysql_link);

$query="INSERT INTO user VALUES('','sdfsdsfdf','sdf','wer','m4n','asa4sd')";  

mysql_query($query,$mysql_link);
if (mysql_affected_rows()==1)
echo "effected";
else
echo "no effect";
yavge
Newbie Poster
1 post since Nov 2008
Reputation Points: 10
Solved Threads: 0
 

try using the query:

$query = "INSERT INTO `user` (`Mail`,`Pass`,`Name`,`LName`,`Details`) VALUES ('sdfsdsfdf','sdf','wer','m4n','asa4sd')";


and if that doesn't work...

add

or die( 'Error: ' . mysql_error() );

to the end of the mysql_query() call and run the script again. let us know if there are any errors.

kkeith29
Nearly a Posting Virtuoso
1,357 posts since Jun 2007
Reputation Points: 235
Solved Threads: 194
 

Well, one more thing - your procedure to check if there is any result will normally return nothing...

1. Store your insert query into a variable like this:

$insret = mysql_query($query,$mysql_link);


2. Now you can check it like this

if ($insert)
 {
  echo "Your new record is".mysql_insert_id($mysql_link);
 }
else {echo mysql_error();}
Rhyan
Posting Whiz in Training
240 posts since Oct 2006
Reputation Points: 21
Solved Threads: 26
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You