n00b needs mySQL help

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
pb2ya
Forum Commoner
Posts: 42
Joined: Sat Jul 06, 2002 5:20 pm
Location: ATL
Contact:

n00b needs mySQL help

Post by pb2ya »

ok, i put this code:

Code: Select all

<?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.... :cry:
DSM
Forum Contributor
Posts: 101
Joined: Thu May 02, 2002 11:51 am
Location: New Mexico, USA

Post by DSM »

Code: Select all

<?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); 
?>
should be

Code: Select all

<?php 
#Connect to the Server 
$conn = @mysql_connect("localhost", "", ""); 
#Select the Database 
mysql_select_db("guestbook", $conn); 
#Send SQL Query 
CREATE TABLE 'users' 
('ID' INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
'UserName' TEXT NOT NULL, 
'SignUpDate' DATE NOT NULL, 
'UserDescription' TEXT )
#Close Connection 
mysql_close($conn); 
?>
[/url]
User avatar
PaTTeR
Forum Commoner
Posts: 56
Joined: Wed Jul 10, 2002 7:39 am
Location: Bulgaria
Contact:

Post by PaTTeR »

The query string should not end with a semicolon.


Code: Select all

mysql_query("CREATE TABLE users 

( 

ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 

UserName TEXT NOT NULL, 

SignUpDate DATE NOT NULL, 

UserDescription TEXT, 

)", 

"$conn");
User avatar
PaTTeR
Forum Commoner
Posts: 56
Joined: Wed Jul 10, 2002 7:39 am
Location: Bulgaria
Contact:

Post by PaTTeR »

00pS the right code is :


Code: Select all

mysql_query("CREATE TABLE users 

( 

ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 

UserName TEXT NOT NULL, 

SignUpDate DATE NOT NULL, 

UserDescription TEXT

)", 

"$conn");
:D
Post Reply