[thelist] Mysql CHAR

Santilal Parbhu santilal at scorpioneng.co.nz
Mon Mar 5 18:40:53 CST 2007


Hi

I am using a PHP script to access a MySQL database.  Not sure of the
versions because both are hosted by  a webhosting service.  When I enter
"SenMens", (without the speech marks) it works fine.  But when I enter "Sen
Mens", i.e with a space, I get an error.  If I use underscore instead of a
space, it works fine.  I am sure that I have used a space elsewhere without
any problems.  Here is the code:

$comppoints=$comppoints.$grd;
					$query = "CREATE TABLE $comppoints (
					row_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
					grade CHAR(25) NOT NULL,
					team_name CHAR(25) NOT NULL,
					won INT(5),
					lost INT(5),
					drawn INT(5),
					ffor INT(5),
					against INT(5),
					points INT(5),
					diff INT(5)
					)";

Below is the error dsiplayed.

Make a DrawCould not create the table because: You have an error in your SQL
syntax near 'Mens ( row_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
grad' at line 1.

The query being run was: CREATE TABLE cohockeypointsSen Mens ( row_id INT
UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, grade CHAR(25) NOT NULL,
team_name CHAR(25) NOT NULL, won INT(5), lost INT(5), drawn INT(5), ffor
INT(5), against INT(5), points INT(5), diff INT(5) )

I think the problem may be related to the fact that the table name is a
concatenation of $comppoints and $grd, and $grd contains a space.  But I
can't see why the error is occurring or how to avoid it.

Has anyone any ideas?

Thanks.

Santilal







More information about the thelist mailing list