Page 1 of 1

I can't insert a row into the table

Posted: Thu Sep 01, 2011 3:17 am
by aneuryzma
hi,

I don't understand why I can't insert a row into the table:
$con = mysql_connect("localhost","mobileApp","mobileApp");

if (!$con) {
die('Could not connect: ' . mysql_error());
}

mysql_select_db('database', $con);

//I'm sure the connection is well established because I can fetch values, however I can't insert them.

mysql_query("INSERT INTO Users (FirstName, LastName, Age)
VALUES ('pinco', 'pass1', 'pass2')"); //doesn't work, row is not added
thanks

Re: I can't insert a row into the table

Posted: Thu Sep 01, 2011 4:06 am
by Dodon
If the Age field is an Interger you can't insert a String.

What is the error you get?

What error do you get if you place the query directly into phpmyadmin?

Re: I can't insert a row into the table

Posted: Thu Sep 01, 2011 4:30 am
by aneuryzma
I don't get any error. The fields are VARCHAR.. is ok ?

Re: I can't insert a row into the table

Posted: Thu Sep 01, 2011 11:43 am
by social_experiment
Does the username you are using have INSERT access?

Code: Select all

<?php
// try this to see if any errors are present
$qry = mysql_query("INSERT INTO Users (FirstName, LastName, Age)
VALUES ('pinco', 'pass1', 'pass2')") or die(mysql_error());
?>