Page 1 of 1
PLZ help... mySQL dosent seem 2 like php on my comp...
Posted: Sat Jul 06, 2002 5:20 pm
by pb2ya
ok, i put this code:
<?php
#Connect to the Server
$conn = @mysql_connect("localhost", "", "");
#Select the Database
mysql_select_db("guestbook", $conn);
#Send SQL Query
mysql_query("CREATE TABLE users
(
ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
UserName TEXT NOT NULL,
SignUpDate DATE NOT NULL,
UserDescription TEXT,
);",
"$conn");
#Close Connection
mysql_close($conn);
?>
and it comes out as this:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource
plz help.... i typed that stuff in the mysql program, and it works perfectly....

Posted: Sat Jul 06, 2002 6:07 pm
by LenHewitt
Kill the '@' and then you will get some feedback as to what's going wrong and add an "or die":
$conn = mysql_connect("localhost", "", "")
or die("couldn't connect" . mysql_error());
Chances are you need a username and password supplying for the connection.
Under Windows the deafault Username is "ODBC"
naw naw
Posted: Sat Jul 06, 2002 6:09 pm
by pb2ya
tha mySQL_connect("localhost", "", ""); thang works perfectly. The only thang wrong is that the sql querys wont work fo some reason
this is tha prollem
Posted: Sat Jul 06, 2002 6:16 pm
by pb2ya
ok, the code is this:
(
Green Text means working code,
RED text means non-working code.)
<?php
#Connect to the Server
$conn = @mysql_connect("localhost", "", "");
#Select the Database
mysql_select_db("guestbook", $conn);
#Send SQL Query
mysql_query("CREATE TABLE users
(
ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
UserName TEXT NOT NULL,
SignUpDate DATE NOT NULL,
UserDescription TEXT,
);",
"$conn");
#Close Connection
mysql_close($conn);
?>
yall PLZ help

Posted: Sat Jul 06, 2002 6:17 pm
by LenHewitt
see next post
Posted: Sat Jul 06, 2002 6:22 pm
by LenHewitt
Try making your query into a variable:
Code: Select all
$query = "CREATE TABLE
users
(ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, UserName TEXT NOT NULL
, SignUpDate DATE NOT NULL
, UserDescription TEXT
)";
$result = mysql_query($query,$conn)
or die("query failed" , mysql_error());
I notice that you do have an unrequired comma after the last item in your query.
still dont work...
Posted: Sat Jul 06, 2002 6:23 pm
by pb2ya
ok, heres the code i put:
$query = "CREATE TABLE users
(
ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
UserName TEXT NOT NULL,
SignUpDate DATE NOT NULL,
UserDescription TEXT,
);"
mysql_query($query, $conn);<--------Line 23
heres tha error:
Parse error: parse error, unexpected T_STRING in
c:\program files\apache group\apache\htdocs\MySQL\sendSQLquery.php on line
23
:) thx
Posted: Sat Jul 06, 2002 6:25 pm
by pb2ya

it worked. thx yall. i owe yall 1
Posted: Sat Jul 06, 2002 6:28 pm
by LenHewitt
Try the code posted in my previous post above. It should solve your problem
The fact that it is reporting an error at Line23 usually means the error is ABOVE that line.
Posted: Mon Jul 08, 2002 4:49 am
by mikeq
$query = "CREATE TABLE users
(
ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
UserName TEXT NOT NULL,
SignUpDate DATE NOT NULL,
UserDescription TEXT,
);" <-----You shouldn't put this semi-colon here
ty it worked
Posted: Mon Jul 08, 2002 1:08 pm
by pb2ya
lol ok, another question:
Posted: Mon Jul 08, 2002 1:14 pm
by pb2ya
ok, i used what u guys taught me to make the aministrator control panel(im makin a message board).
now, i made the user signup page:
Code: Select all
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Signup to the MessageBoards</title>
</head>
<body>
<h1>Message Boards</h1>
<h2>User Signup</h2>
<form method="post" action="signup2.php">
<h3>Type in your desired username:<br /></h3>
<input type="text" name="username">
<h3>Type in your desired password:<br /></h3>
<input type="password" name="password">
<br />
<input type="submit" value="Submit" name="submit" /><input type="reset" value="Reset" />
</form>
</body>
</html>
then the signup2.php page:
Code: Select all
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP page</title>
</head>
<body>
<?php
$newusername = $HTTP_POST_VARSї"username"];
$newpassword = $HTTP_POST_VARSї"password"];
$conn = mysql_connect("localhost", "", "");
mysql_select_db("guestbook", $conn);
$query = "INSERT INTO users(username, password) VALUES ($newusername, $newpassword)";
$result = mysql_query($query,$conn)or die("query failed");
if ($result != FALSE)
{
echo"Query Was Made.";
}
else
{
echo"Query was not made";
}
?>
</body>
</html>
again, it dosent work. im thinking because of the INSERT INTO thing where im using variables. plz help.
nevermind
Posted: Mon Jul 08, 2002 1:19 pm
by pb2ya
i fixed it myself dont reply.