Won't insert into the database....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Getran
Forum Commoner
Posts: 59
Joined: Wed Aug 11, 2004 7:58 am
Location: UK
Contact:

Won't insert into the database....

Post by Getran »

i have a simple script for users to signup, everything should work but doesn't. When i click submit i get no errors, but it doesn't get put into the database...

is there anything wrong in this query ?:

Code: Select all

$insert_query = mysql_query("INSERT INTO accounts ( `id` , `fname` , `sname` , `age` , `sex` , `username` , `password` , `email` , `colonyname` , `charactername`)" . "VALUES ('NULL', '$fname', '$sname', '$age', '$sex', '$uname', '$pass', '$emailaddy', '$colname', '$charname')");
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you aren't trying to insert the values you are passing..

Code: Select all

$insert_query = mysql_query("INSERT INTO accounts ( `id` , `fname` , `sname` , `age` , `sex` , `username` , `password` , `email` , `colonyname` , `charactername`) VALUES ('NULL', '$fname', '$sname', '$age', '$sex', '$uname', '$pass', '$emailaddy', '$colname', '$charname')") or die(mysql_error());
mysql doesn't kick out error's directly into php on it's own, adding "or die(mysql_error())" after several of the mysql function calls will show these errors to you when they happen.
Getran
Forum Commoner
Posts: 59
Joined: Wed Aug 11, 2004 7:58 am
Location: UK
Contact:

Post by Getran »

ok i did that, but now the page just goes completely blank when i submit -_-
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it sounds like you don't have your error level high enough, or your errors being displayed... if you can, edit your php.ini file to have an error_level of E_ALL and display_errors of On.

If you are unable to edit your php.ini, you can set them at runtime, however this does not show parse errors most often

Code: Select all

<?php

error_reporting(E_ALL);
ini_set('display_errors','1');

?>
place those 2 lines at the top of your script(s)
Post Reply