Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/77850-solved-wrong-prameter/
Share on other sites

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>"

Link to comment
https://forums.phpfreaks.com/topic/77850-solved-wrong-prameter/#findComment-394034
Share on other sites

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>";
?>

Link to comment
https://forums.phpfreaks.com/topic/77850-solved-wrong-prameter/#findComment-394050
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.