Mystic Software Forums

Mystic Software => General Discussion => Topic started by: DarkElite on March 11, 2007, 01:43:35 PM

Title: MySQL
Post 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?
Title: Re: MySQL
Post by: Michael J. Hill on March 12, 2007, 06:30:49 AM
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.
Title: Re: MySQL
Post by: Xorlak on March 12, 2007, 10:40:34 AM
Send me a PM with a username, password, and a name for your database and I can set it up for you.
Title: Re: MySQL
Post by: DarkElite on March 25, 2007, 01:25:19 PM
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...
Title: Re: MySQL
Post by: Michael J. Hill on March 26, 2007, 07:11:16 AM
Quote from: "DarkElite"
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.
Title: Re: MySQL
Post by: drcrazy4 on March 28, 2007, 10:22:40 AM
Code: [Select]
$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:
Code: [Select]
$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.
Title: Re: MySQL
Post by: Michael J. Hill on March 29, 2007, 11:14:34 AM
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.
Title: Re: MySQL
Post by: drcrazy4 on April 16, 2007, 09:35:49 AM
PHP does parse single quotes but you need to do it like this:
Code: [Select]
'.$var.'unless you are using it in a mySQL query.