Insert Not working

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
mikeo007
Forum Newbie
Posts: 1
Joined: Fri Nov 11, 2005 12:33 pm

Insert Not working

Post by mikeo007 »

Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Hi, this is my first post on the board.  I'm currently trying to make a simple login system for my webpage.  I have already set up the ability to login by comparing values in a form to values from a database.  Now I want to implement the ability to add a new user to the database, but I'm stuck.  Here is the code that is not working.

Code: Select all

$mysql = mysqli_connect( 'localhost', 'root', '');

$selected = mysqli_select_db( $mysql, 'auth' );

$query = "insert into authorized_users values("$_POST['name'], $_POST['password'], $_POST['fname'], $_POST['lname'], $_POST['email']");
$result = mysqli_query("$mysql, $query);
The database doesn't update from this query, and I have no idea why.
I'm sure it's something stupid that I've overlooked...I'm pretty new to php and mysql so any help would be appreciated.


Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

i'd do two things...
1) store those posts into variables and then when inserting go values('$variablename1','$variablename2',etc)
2) I also generally declare the columns I'm putting the values in, not sure if it's required because it's just something I've always done...
Post Reply