Mystic Software Forums
Mystic Software => General Discussion => Topic started by: DarkElite on March 11, 2007, 01:43:35 PM
-
Kinda getting familiarized with the stuff right now.
I've been trying to access MSs MySQL server via PHP (assuming we have one?), but have come up with an access request denied prompt. How do I connect to the appropriate server or what parameters do I use in the mysql_connect() command?
-
There are separate databases as we need them, each with their own username and passwords to log on to. There is no anonymous access. You'll have to request your own to use for your own purposes. It's too early for me, and I'm in a rush, so I can't set it up right now.
-
Send me a PM with a username, password, and a name for your database and I can set it up for you.
-
Bleh. I'm trying to reference a _POST variable in a mySQL function from a form.
$result = mysql_query("SELECT * FROM loginInfo WHERE usernameS=$_POST['username']");
Probably get laughed at for the syntax, but I'm not sure how to write it in this case...
-
Bleh. I'm trying to reference a _POST variable in a mySQL function from a form.
$result = mysql_query("SELECT * FROM loginInfo WHERE usernameS=$_POST['username']");
Probably get laughed at for the syntax, but I'm not sure how to write it in this case...
That is, technically, correct, though you may want to try and see if this works:
$result = mysql_query("SELECT * FROM loginInfo WHERE usernameS=" .$_POST['username']);
While that is also a possible version, I can't be totally certain that it will work. Make notice of the placement of the ending quotation, and the period.
-
$username = $_POST['username'];
$result = mysql_query("SELECT * FROM loginInfo WHERE usernameS = '$username'") or die(mysql_error());
That's how I do it. It's because you have the 's in the $_POST variable. It works without them eg:
$result = mysql_query("SELECT * FROM loginInfo WHERE usernameS = '$_POST[username]'") or die(mysql_error());
Although it's more efficient to do it the other way. You might wanna do mysql_real_escape_string on the username var as well for a little security.
If you do need any help with PHP and mySQL just PM me.
-
Another mention though, PHP does not parse variables in single quotes. Only double quotes. Whether that extends to single quotes within double quotes, I can't be certain.
-
PHP does parse single quotes but you need to do it like this:
'.$var.'
unless you are using it in a mySQL query.