Lamez Posted November 18, 2007 Share Posted November 18, 2007 I am trying to add tables to my database, but I get this error Warning: Wrong parameter count for mysql_query() in /mounted-storage/home48c/sub007/sc33591-LWQU/www/install/install_2.php on line 54 Could not create tables because here is line 54 mysql_query($user, $auser, $guest, $ban) here is the whole script <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Database Installer</title> </head> <body> <h1>Adding Tables to Database (Step 2 of 3)</h1> <p>This will add the tables needed to the database </p> <p> </p> </body> </html> <?php include ("../_bin_/config.php"); // connect to the mysql server $link = mysql_connect($DB_SERVER, $DB_USER, $DB_PASS) or die ("Could not connect to mysql because ".mysql_error()); // select the database mysql_select_db($DB_NAME) or die ("Could not select database because ".mysql_error()); // create tables on database $user = "create table users ( username varchar(30) primary key, password varchar(32), userid varchar(32), userlevel tinyint(1) unsigned not null, email varchar(50), timestamp int(11) unsigned not null )"; $auser = "create table active_users ( username varchar(30) primary key, timestamp int(11) unsigned not null )"; $guest = "create table active_users ( username varchar(30) primary key, timestamp int(11) unsigned not null )"; $ban = "create table banned_users ( username varchar(30) primary key, timestamp int(11) unsigned not null )"; mysql_query($user, $auser, $guest, $ban) or die ("Could not create tables because ".mysql_error()); echo "Tables have been installed."; echo "<a href=install_3.php>Click here to continue</a>" ?> What am I doing wrong?? -Thanks Guys Quote Link to comment https://forums.phpfreaks.com/topic/77850-solved-wrong-prameter/ Share on other sites More sharing options...
thebadbad Posted November 18, 2007 Share Posted November 18, 2007 Check the manual. mysql_query() can't have multiple query strings; use 4 mysql_query's instead. Quote Link to comment https://forums.phpfreaks.com/topic/77850-solved-wrong-prameter/#findComment-394031 Share on other sites More sharing options...
Lamez Posted November 18, 2007 Author Share Posted November 18, 2007 so instead of doing it in whole query I have to make 4 separate ones? ex: mysql_query($user) mysql_query($auser) mysql_query($guest) mysql_query($ban) or die ("Could not create tables because ".mysql_error()); echo "Tables have been installed."; echo "<a href=install_3.php>Click here to continue</a>" Quote Link to comment https://forums.phpfreaks.com/topic/77850-solved-wrong-prameter/#findComment-394034 Share on other sites More sharing options...
thebadbad Posted November 18, 2007 Share Posted November 18, 2007 Yes. With the code you just posted, the script will only die if the last query fails. And remember a semi-colon at the end of each line. <?php mysql_query($user) or die("Could not create table because ".mysql_error()); mysql_query($auser) or die("Could not create table because ".mysql_error()); mysql_query($guest) or die("Could not create table because ".mysql_error()); mysql_query($ban) or die("Could not create table because ".mysql_error()); echo "Tables have been installed."; echo "<a href=install_3.php>Click here to continue</a>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/77850-solved-wrong-prameter/#findComment-394050 Share on other sites More sharing options...
Lamez Posted November 18, 2007 Author Share Posted November 18, 2007 ok it gets all the way the the active user's table, then it says it already exists and will not add the other tables it only adds the user table, and the active user's table. How can I fix this -Thanks Quote Link to comment https://forums.phpfreaks.com/topic/77850-solved-wrong-prameter/#findComment-394055 Share on other sites More sharing options...
flhtc Posted November 18, 2007 Share Posted November 18, 2007 Your original code has active_users in twice. Once for ausers= and again for guest =. I would say you should change the second one to guest_users. Quote Link to comment https://forums.phpfreaks.com/topic/77850-solved-wrong-prameter/#findComment-394058 Share on other sites More sharing options...
Lamez Posted November 18, 2007 Author Share Posted November 18, 2007 man I feel dumb, always relying on others to debug my code for me. Sorry about that! Quote Link to comment https://forums.phpfreaks.com/topic/77850-solved-wrong-prameter/#findComment-394060 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.