TNS
-
Posts
2 -
Joined
-
Last visited
Never
Posts posted by TNS
-
-
I don't know if this is a PHP question, or a MySQL question, so please move this if it's in the wrong forum. Anyway, here goes:
One of my friends wants to have a page that he can go to and assign points to members of his Halo 2 clan. I've started out extremely simple, but I can't use $gamertag or $points variables in some sql queries and I can in others.
I haven't gotten to checking for existing tables, so I have been switching back and forth between the two $query lines. Here is my code:
<html> <head> <title> </title> </head> <body> <?php print("Gamertag = $gamertag<br>\n"); print("Points = $points<br>\n"); //$query = 'INSERT INTO $gamertag VALUES ($points)'; //$gamertag and $points variables do not work $query = "CREATE TABLE $gamertag (points int(3) NOT NULL default '0') TYPE=MyISAM"; //$gamertag variable works $link = mysql_connect('localhost', 'the-bebo_thetaco', '*********); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully<br>'; mysql_select_db ("the-bebo_paus"); $result = mysql_query($query); if (!$result) { $message = 'Invalid query: ' . mysql_error() . "<br>\n"; $message .= 'Whole query: ' . $query; die($message); } mysql_close($link); ?> </body> </html>
Any ideas?
variables in queries
in Microsoft SQL - MSSQL
Posted
Ok, I was premature in my posting. The problem was that I had used single quotes in some places. I changed my INSERT query to the following code, and it worked perfectly.