avelonx 06-25-2002, 01:18 PM Warning: Wrong parameter count for mysql_db_query() in /home/virtual/site8/fst/var/www/html/runeweb/auth.inc.php on line 277
Warning: Wrong parameter count for mysql_db_query() in /home/virtual/site8/fst/var/www/html/runeweb/auth.inc.php on line 286
---------------------
277 is $sql="SELECT * FROM uuser WHERE user_name='$user_name'";
286 is $sql="INSERT INTO uuser (user_name,real_name,password,email,remote_addr,confirm_hash,is_confirmed) ".
What is wrong? :( :confused: :mad:
whackaxe 06-25-2002, 02:04 PM for the first, you have to
A) take out the ' marks
$sql="SELECT * FROM uuser WHERE user_name=$user_name";
or
B)write your code with the concat character
$sql="SELECT * FROM uuser WHERE user_name=".$user_name;
avelonx 06-25-2002, 05:30 PM Im still getting same error
Spookster 06-25-2002, 08:09 PM In the table that you are inserting values into are these all the fields in that table?
user_name
real_name
password
email
remote_addr
confirm_hash
is_confirmed
An insert statement works in this way:
INSERT INTO tablename (field1, field2) VALUES (value1, value2)
In which case the values correspond to the matching field name in order.
In your insert statement you are missing the values section. So in your case your insert statement should look something like:
$sql="INSERT INTO uuser (user_name,real_name,password,email,remote_addr,co
nfirm_hash,is_confirmed) VALUES ($user_name, $password, $email, $remote_addr, $confirm_hash, $is_confirmed)"
assuming that you have those other values stored in variables as well.
avelonx 06-25-2002, 09:38 PM At the top of my script:
create table uuser (
user_id int not null auto_increment primary key,
user_name text,
real_name text,
email text,
password text,
remote_addr text,
confirm_hash text,
is_confirmed int not null default 0
);
avelonx 06-25-2002, 09:44 PM :rolleyes: Still doesnt work...
Can I maybe email you the code Spookster?
Spookster 06-25-2002, 09:53 PM Oh ok so you have an auto increment field in there. Then try this. Note I forgot to put the quotes into the last one:
$sql="INSERT INTO uuser (user_id, user_name,real_name,password,email,remote_addr,confirm_hash,is_confirmed) VALUES ('NULL','$user_name','$password','$email','$remote_addr','$confirm_hash','$is_confirmed')"
or since you are inserting values into every field you can leave out the field names like so:
$sql="INSERT INTO uuser VALUES ('NULL','$user_name','$password','$email','$remote_addr','$confirm_hash','$is_confirmed')"
On a side note.........
Warning: Wrong parameter count for mysql_db_query()
Can I just ask quickly how many parameters you are passing in
the above named query (probably a line or two below your $x =
"SELECT *....." line.
You need at least two params
mysql_db_query('databasename',$queryreference)
or
mysql_db_query('databasename',$queryreference,resource_link_identifier)
if you are not using multiple databases - or have the database
defined in the mysql_connect bit - you may want to just use
mysql_query($queryreference);
As the error return is pointing directly at that function, can you
test that before testing the value of the $queryreference.
Subnote: Text editors that tell you which line of a script you are
on can often yield different results to the error return - 'specially
if you have included subscripts and blank lines
avelonx 06-26-2002, 01:32 AM Argh. What else could I have done wrong?
I've made sure the table was created.
I've made sure the table contained the proper fields
I've made sure the Mysql Username and Password e.t.c are correct.
I get no errors
just a blank page :(
Spookster 06-26-2002, 01:57 AM no errors? and you say the table was created? so is the insert statement working as well? If not post all the code that you are using to connect to the db as well as any other code you are using to interact with the db.
firepages 06-26-2002, 10:21 AM run this (just this) and post the returned error...
mysql_connect('localhost',$user,$pass)or die(mysql_error());
mysql_select_db($database)or die(mysql_error());
$sql="INSERT INTO uuser VALUES ('$user_name','$password','$email','$remote_addr','$confirm_hash','$is_confirmed')";
mysql_query($sql)or die(mysql_error());
avelonx 06-26-2002, 03:06 PM hmm Error was
Column count doesn't match value count at row 1
whackaxe 06-26-2002, 03:40 PM i think that you have to put "INSERT INTO uuser(colum1, colum2,..) values (value1, value2,)
with mySQL if you the number of values you are trying to insert isnt equal to the number of colums in the table then it wront just put the values in any old colum, it will return the error you got
Spookster 06-26-2002, 03:57 PM and try it again with this:
mysql_connect('localhost',$user,$pass)or die(mysql_error());
mysql_select_db($database)or die(mysql_error());
$sql="INSERT INTO uuser VALUES ('NULL','$user_name','$password','$email','$remote_addr','$confirm_hash','$is_confirmed')";
mysql_query($sql)or die(mysql_error());
avelonx 06-26-2002, 05:02 PM Same error , Spook
whackaxe 06-26-2002, 06:35 PM try 0 instead of null (without or without " "? dont know about that) did you check you were inserting the same amount of values as tables colums. if you arent then look at my last post
firepages 06-26-2002, 06:39 PM doh sorry - whackaxe is correct
<?
mysql_connect('localhost',$user,$pass)or die(mysql_error());
mysql_select_db($database)or die(mysql_error());
$sql="INSERT INTO uuser (user_name,password,email,remote_addr,confirm_hash,is_confirmed) VALUES ('$user_name','$password','$email','$remote_addr','$confirm_hash','$is_confirmed')";
mysql_query($sql)or die(mysql_error());
?>
Spookster 06-26-2002, 06:46 PM Ok and once more with this. Note I removed the quotes around the null. Since it is dealing with an auto increment field the null simply tells that field to insert whatever value it is suppose to which in this case it just increments a number
mysql_connect('localhost',$user,$pass)or die(mysql_error());
mysql_select_db($database)or die(mysql_error());
$sql="INSERT INTO uuser VALUES (NULL,'$user_name','$real_name','$password','$email','$remote_addr','$confirm_hash','$is_confirmed')";
mysql_query($sql)or die(mysql_error());
If there are still problems then we will need to see all of your code.
ps. that's what i get for copying and pasting firepages code. fp you left out a few of the fields.
whackaxe 06-26-2002, 07:02 PM nobody listens to me....:(
avelonx 06-26-2002, 08:17 PM I test Spook's and FP's. They both did the same. They made no errors and they did interact with the database
PHPMYADMIN:
user_id keeps increasing by 1 number each time I run the script.
and is_confirmed is always zero
0 meaning the account has not been confirmed
.. but how do i reset the user_id back to 0 :P
and now that i've ran these codes wat do I do now :P... place them in my script?
Spookster 06-26-2002, 11:19 PM Of course we listen to you whacky. :)
Aveon, the sql is working if it is inserting the records. That was your original question/problem. What is it that you need now? Truncate the table if you want to start the user_id back to zero. Of course that may not work with an autoincrement field.
avelonx 06-27-2002, 01:52 AM I placed it in my script and now its returning a blank page :| .. its suppose to echo some text .. it doesnt do anything to the database either..
Spookster 06-27-2002, 03:25 AM If you want to echo the data to the page then simply use some echo statements. What does it not do to the database?
avelonx 06-27-2002, 03:55 AM The script calls on a function and that function checks if the username exists if it does it echoes an error it not it connects to the database and inserts the data and echoes that it was succesful. I am positive it is calling the function correctly. It is just returning a blank page. :(
Spookster 06-27-2002, 04:30 AM Well post your code and we can take a look at it.
wabirdman 06-27-2002, 08:44 AM I just noticed something while reading through this post.
Here is the create table code
create table uuser (
user_id int not null auto_increment primary key,
user_name text,
real_name text,
email text,
password text,
remote_addr text,
confirm_hash text,
is_confirmed int not null default 0
);
Here is the insert code
INSERT INTO uuser
(
user_id,
user_name,
real_name,
password,
email,
remote_addr,
confirm_hash,
is_confirmed
)
VALUES
(
'NULL',
'$user_name',
'$password',
'$email',
'$remote_addr',
'$confirm_hash',
'$is_confirmed'
)
You are trying to insert NULL into a field that has been defined as NOT NULL. Also you have 8 fields in the table, 8 fields in the insert part of the insert statement, yet only 7 fields in the values section of the insert statement.
You need something like this
VALUES
(
'',
'$user_id',
'$user_name',
'$real_name',
'$email',
'$password',
'$remote_addr',
'$confirm_hash',
'$is_confirmed'
);
wabirdman
avelonx 06-27-2002, 12:45 PM I thought $userid was an auto_increment..
avelonx 06-27-2002, 12:52 PM Another error has somehow popped up.
Parse error by the way.
$G_USER_RESULT=mysql_query("SELECT * FROM user WHERE user_name='" . user_getname() . "'");
Spookster 06-27-2002, 01:21 PM Originally posted by wabirdman
I just noticed something while reading through this post.
It's okay. The null is simply telling the auto increment to insert a value of whatever it needs to. I believe I explained that it in a previous post.
wabirdman 07-01-2002, 01:08 AM It's okay. The null is simply telling the auto increment to insert a value of whatever it needs to. I believe I explained that it in a previous post.
I understand that, but there is still the issue of inserting 7 values into 8 fields.
wabirdman
Spookster 07-01-2002, 02:32 AM Originally posted by wabirdman
I understand that, but there is still the issue of inserting 7 values into 8 fields.
wabirdman
The insert statement I posted is inserting 8 values into 8 fields. Or did I miss something?
wabirdman 07-05-2002, 02:20 AM Yes you guys had this as the insert statement
INSERT INTO uuser
(
user_id, --1
user_name, --2
real_name, --3
password, --4
email, --5
remote_addr, --6
confirm_hash, --7
is_confirmed --8
)
VALUES
(
'NULL', --2
'$user_name', --3
'$password', --4
'$email', --5
'$remote_addr', --6
'$confirm_hash', --7
'$is_confirmed' --8
)
You still have to have
' ', for the first value
wabirdman
Spookster 07-05-2002, 02:30 AM This is the insert statement I posted:
INSERT INTO uuser VALUES (NULL,'$user_name','$real_name','$password','$email','$remote_addr','$confirm_hash','$is_confirmed')";
I count 8 values. I could be wrong though.
;)
wabirdman 07-05-2002, 03:00 AM I must have read the wrong insert statement then :)
wabirdman
|
|