prcollin Posted July 25, 2008 Share Posted July 25, 2008 Ok same code different problem. When i submit the form that corresponds to this code the auto number goes up and all zeros show up in the respective interger fields but no information is entered into the database other than the autonumber. <?php include "clientconnect.php"; include "newclient.html"; mysql_select_db('greencut_customercenter', $con); $client_id = mysql_real_escape_string($_POST['client_id']); $client_fname = mysql_real_escape_string($_POST['client_fname']); $client_lname = mysql_real_escape_string($_POST['client_lname']); $client_address = mysql_real_escape_string($_POST['client_address']); $client_city = mysql_real_escape_string($_POST['client_city']); $client_state = mysql_real_escape_string($_POST['client_state']); $client_zipcode = mysql_real_escape_string($_POST['client_zipcode']); $client_phone = mysql_real_escape_string($_POST['client_phone']); $client_cphone = mysql_real_escape_string($_POST['client_cphone']); $client_email = mysql_real_escape_string($_POST['client_email']); $client_website = mysql_real_escape_string($_POST['client_website']); $client_notes = mysql_real_escape_string($_POST['client_notes']); $sql = "insert into clients values ('$client_id', '$client_fname', '$client_lname', '$client_address', '$client_city', '$client_state', '$client_zipcode', '$client_phone', '$client_cphone', '$client_email', '$client_website', '$client_notes')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con); ?> Quote Link to comment https://forums.phpfreaks.com/topic/116522-getting-no-value-inputs-in-database/ Share on other sites More sharing options...
blueman378 Posted July 25, 2008 Share Posted July 25, 2008 have you checked if your post values are what you expect? Quote Link to comment https://forums.phpfreaks.com/topic/116522-getting-no-value-inputs-in-database/#findComment-599136 Share on other sites More sharing options...
$username Posted July 25, 2008 Share Posted July 25, 2008 Might want to try something like this $sql = "insert into clients (clientid) values ('$client_id'')"; make sure the field is listed than the value Brett Quote Link to comment https://forums.phpfreaks.com/topic/116522-getting-no-value-inputs-in-database/#findComment-599205 Share on other sites More sharing options...
prcollin Posted July 25, 2008 Author Share Posted July 25, 2008 Might want to try something like this $sql = "insert into clients (clientid) values ('$client_id'')"; make sure the field is listed than the value Brett getting an error that says "duplicate entry for key 2" no clue what that means Quote Link to comment https://forums.phpfreaks.com/topic/116522-getting-no-value-inputs-in-database/#findComment-599440 Share on other sites More sharing options...
JonnoTheDev Posted July 25, 2008 Share Posted July 25, 2008 Remove the single quotes around your php variables! values ($client_id, $client_fname or values ('".$client_id."', '".$client_fname."' Quote Link to comment https://forums.phpfreaks.com/topic/116522-getting-no-value-inputs-in-database/#findComment-599443 Share on other sites More sharing options...
JonnoTheDev Posted July 25, 2008 Share Posted July 25, 2008 also are you supplyinmg the correct number of fields for values. You said you had an auto incremental key so there should be: values ('', '".$field1."' It is much better writing: SET name='".$name."', address='".$address."' etc Quote Link to comment https://forums.phpfreaks.com/topic/116522-getting-no-value-inputs-in-database/#findComment-599446 Share on other sites More sharing options...
MFHJoe Posted July 25, 2008 Share Posted July 25, 2008 Remove the single quotes around your php variables! Usually that'd be a good idea but not here. $sql is actually in double quotes which allow variables to be used inside them. Without the single quotes, $sql would look like: $sql = "insert into clients values (1, Firstname, Lastname, etc.... Which would result in a mySQL error as the values need to be denoted by single quotes. Quote Link to comment https://forums.phpfreaks.com/topic/116522-getting-no-value-inputs-in-database/#findComment-599448 Share on other sites More sharing options...
JonnoTheDev Posted July 25, 2008 Share Posted July 25, 2008 Just a style preference I have values ('".$client_id."', '".$client_fname."' I hate this sort of query using the "VALUE" syntax, especially if you modify the structure of your table and forget about queries written like this. SET is much more efficient as the order of fields makes no difference. Quote Link to comment https://forums.phpfreaks.com/topic/116522-getting-no-value-inputs-in-database/#findComment-599450 Share on other sites More sharing options...
prcollin Posted July 25, 2008 Author Share Posted July 25, 2008 get error check sal syntax near ') at line one values ($client_id, $client_fname get duplicate entry still and no values input. values ('".$client_id."', '".$client_fname."' number of fields and name of fields are correct Quote Link to comment https://forums.phpfreaks.com/topic/116522-getting-no-value-inputs-in-database/#findComment-599452 Share on other sites More sharing options...
prcollin Posted July 25, 2008 Author Share Posted July 25, 2008 now i get this error Error: Duplicate entry '' for key 2 Quote Link to comment https://forums.phpfreaks.com/topic/116522-getting-no-value-inputs-in-database/#findComment-599456 Share on other sites More sharing options...
JonnoTheDev Posted July 25, 2008 Share Posted July 25, 2008 My code sinppets are not complete and wont work. They are just examples to get you on the right track. If you have a duplicate key then get rid of the bad value and make sure that you definately have an auto incremental field for your primary key an no other uniques indexes on fields taht may product the error. If there are values in your variables. I assume that you have tested this then this code will work (I have assumed the names of your database fields so make sure that you change them in the following SQL): $sql = "INSERT INTO clients SET client_id='".$client_id."', client_fname='".$client_fname."', client_lname='".$client_lname."', client_address='".$client_address."', client_city='".$client_city."', client_state='".$client_state."', client_zipcode='".$client_zipcode."', client_phone='".$client_phone."', client_cphone='".$client_cphone."', client_email='".$client_email."', client_website='".$client_website."', client_notes='".$client_notes."')"; Quote Link to comment https://forums.phpfreaks.com/topic/116522-getting-no-value-inputs-in-database/#findComment-599459 Share on other sites More sharing options...
prcollin Posted July 25, 2008 Author Share Posted July 25, 2008 My code sinppets are not complete and wont work. They are just examples to get you on the right track. If you have a duplicate key then get rid of the bad value and make sure that you definately have an auto incremental field for your primary key an no other uniques indexes on fields taht may product the error. If there are values in your variables. I assume that you have tested this then this code will work (I have assumed the names of your database fields so make sure that you change them in the following SQL): $sql = "INSERT INTO clients SET client_id='".$client_id."', client_fname='".$client_fname."', client_lname='".$client_lname."', client_address='".$client_address."', client_city='".$client_city."', client_state='".$client_state."', client_zipcode='".$client_zipcode."', client_phone='".$client_phone."', client_cphone='".$client_cphone."', client_email='".$client_email."', client_website='".$client_website."', client_notes='".$client_notes."')"; no matter how i change the format around, mess with the db it says duplicate entry for key 2 any ideas still? Quote Link to comment https://forums.phpfreaks.com/topic/116522-getting-no-value-inputs-in-database/#findComment-599620 Share on other sites More sharing options...
blueman378 Posted July 31, 2008 Share Posted July 31, 2008 do a database structure export and post it here (in code tags) and we may be able bo help Quote Link to comment https://forums.phpfreaks.com/topic/116522-getting-no-value-inputs-in-database/#findComment-605030 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.