[help] Error trying to add to database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
painful-one
Forum Newbie
Posts: 11
Joined: Tue Jan 05, 2010 11:26 am

[help] Error trying to add to database

Post by painful-one »

abushahin wrote:
Hey to insert data into db you need to create a form then let php insert it for you, to retrieve data you'll need to create a form to retrieve it for you. you can have a look at hows its done here

<<http://abushahin.eu/tutorials/insertdata.php>>

Hey, hope you can help me. If not, thanks anyway.

I checked out the website you sent me and set everything up but I am still getting a DB error. This is what I have so far. I have a login for users (as of right now I have to manually add the information to create a new member in the members table, which is fine at the moment). It checks the username and password, connects on success. I want them to be able to change the information in the database, so as they progress, they can change it. I did the tutorial you sent me and I get this error;

Parse error: syntax error, unexpected ';' in /home/content/96/4742196/html/add.php on line 9

Line 9 is;

mysql_query("INSERT INTO members VALUES('$charname')" or die ('Error, INSERT to users query failed');

I changed everything to charname on the html/php side and whatnot.

And ideas?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: [help] Error trying to add to database

Post by AbraCadaver »

Syntax errors mean that you have mistyped something or are missing something that needs a match such as a quote or parentheses. In your case it's parentheses on that line.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
painful-one
Forum Newbie
Posts: 11
Joined: Tue Jan 05, 2010 11:26 am

Re: [help] Error trying to add to database

Post by painful-one »

So what do I change? Where do I put them?
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: [help] Error trying to add to database

Post by Darhazer »

Code: Select all

mysql_query("INSERT INTO members VALUES('$charname')" or die ('Error, INSERT to users query failed');
 
Should be

Code: Select all

mysql_query("INSERT INTO members VALUES('$charname')") or die ('Error, INSERT to users query failed');
 
Post Reply