Free Web Hosting Forum
(#1 (permalink))
Old
Junior Member
mhutti1 is on a distinguished road
 
Posts: 21
Join Date: Apr 2012
Question SQL insert problem - 04-24-2012, 11:56 AM

This code for creating users does not work
PHP Code:
$connect5=mysql_connect("SERVER","USERNAME","PASSWORD") or die ("Could not connect to database");

mysql_select_db("DATABASE") or die ("Could not find database");

$query10 mysql_query("INSERT INTO members VALUES ('','$username','$enc_password','$name','Private')") or die("error"); 
It seems to connect fine however the insert into statement triggers the error message and consequently no user is created. Does anyone know why this is?
Reply With Quote
Sponsored Links
(#2 (permalink))
Old
d3iti's Avatar
Super Moderator
d3iti is on a distinguished road
 
Posts: 6,515
Join Date: Jul 2009
Location: Spain
Default 04-24-2012, 12:23 PM

Hello,

Your members table have EXACTLY 5 fields? If it have not exactly 5 fields you can not use the short form for INSERT.

In PHP variables, are you used in your SQL query is there any value?

Try to modify the end of your statement to see if MySQL will return an error:
PHP Code:
$query10 mysql_query("INSERT INTO members VALUES ('','$username','$enc_password','$name','Private')") or die("Error:" .mysql_error()); 


Recuerda realizar copias de seguridad de tus sitios web. Si este mensaje te ayudó puedes pulsar sobre el botón karma
Reply With Quote
(#3 (permalink))
Old
Junior Member
mhutti1 is on a distinguished road
 
Posts: 21
Join Date: Apr 2012
Default 04-24-2012, 04:09 PM

I had just added an extra field to my table so there were 6 fields not 5. Thanks very much for the help I altered the code and now it works.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com