In the past, I have had MySQL installed on my PC, made it a server and hosted internal websites on it. I have run queries on the MySQL database, both manually and using a PHP form.
However, I now don’t have that PC, and want to host something for the world to see. I’ve got an account with a host that provides MySQL databases, and I’ve started setting up my site. However, the query syntax I’ve used in the past doesn’t seem to work. Previously, I’ve entered things like:
SELECT (first) AS first, (last) AS last FROM names
However, this remote server tells me there is a problem with my syntax. It doesn’t seem to like me using AS, or the commas, and it certainly doesn’t like the brackets. By entering:
SELECT ‘first’ ‘last’ FROM names
I managed to get something, but not the data I was after. I know this isn’t the forum for detailed MySQL questions, but if someone could just tell me if I have a different type of MySQL that I should look for manuals on, I’ll go and do it. Apparently I’m on MySQL 4.0.26, which according to all the online info I can find, should use the () syntax in my first example.
My fault for not actually copying and pasting the actual query I’ve run - that was just an example of the syntax I’ve used, not the actual query. I have in fact changed the reference names, to see if it helped, but it didn’t. This is from my script:
I see that you are using '$" before each variable, assume that you are using PHP. Here’s a PHP-based SQL statement which works for me:
// Create the SQL statement to add the user to the database.
$sql = "INSERT INTO user (username, userpassword, useremail, usergender, useraddress)";
$sql .= " VALUES ( \"$userName\", password(\"$userPassword\"), \"$userEmail\", $userGender, \"$userAddress\")";
If I remember correct, you might have to escape the single quote too…