0

Hey guys, only new to Daniweb, so pardon me, if i seem too "nooby" for you guys.

I am building a website, and currently am working on the "members area"
i have a database named "users" with fields "name", "username", "email", and "password".
i am running a php script, and haved tested myself (by "echoing" until i find the line that screws up) that this line of code

$sql = mysql_query("INSERT INTO c944978_member_database.users (name, email, username, password)
		VALUES('$name', '$email', '$username', '$db_password'") or die (mysql_error());

when the php file gets to this line it gives this error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2

Not sure what this means, have done some googling, and found that it is too do with the SQL Database.. but am very new to this so cant find my error.

my sql database is:

CREATE TABLE users (
  userid int(25) NOT NULL auto_increment,
  name varchar(25),
  email varchar(25),
  username varchar(25),
  password varchar(255),
  PRIMARY KEY  (userid)
) TYPE=MyISAM COMMENT='Membership Information';

I got this as a template from, www.1stoptutorials.com, where i watched tutorials, and changed some of the code to suit my website.

If somebody can point out, why im getting this error, it would be much appreciated :)

James, Gobble45

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by simplypixie
0

Nevermind guys, i have asked a friend of mine, and he has shown me the answer;
change the php file to say

$sql = mysql_query("INSERT INTO c944978_member_database.users (name, email, username, password)
  VALUES('$name', '$email', '$username', '$db_password')");

Rather than what was there.
Just so anybody else with this issue, can learn :)

0

All you are doing here is removing the error message, you are not solving the error itself.

To me it appears that you are trying to user database_name.table_name to connect to your database and insert your data all within your insert query which I have never seen before in all my years of programming.

1st make your connection to the database and then run your query, therefore changing c944978_member_database.users to just users.

0

All you are doing here is removing the error message, you are not solving the error itself.

To me it appears that you are trying to user database_name.table_name to connect to your database and insert your data all within your insert query which I have never seen before in all my years of programming.

1st make your connection to the database and then run your query, therefore changing c944978_member_database.users to just users.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.