Author Topic: MySQL  (Read 3130 times)

DarkElite

  • Member
  • *
  • Posts: 1452
    • View Profile
    • http://cryosoft.mysticsoftware.net/Home.html
MySQL
« 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?
« Last Edit: December 31, 1969, 06:00:00 PM by Guest »
DarkElite

Dei vobem omniam proditiverunt.  Iam vobis quis deposcibitis sacrificium rersum vitae est!

Michael J. Hill

  • Member
  • *
  • Posts: 244
    • View Profile
    • http://ls.mysticsoftware.net/
Re: MySQL
« Reply #1 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.
« Last Edit: December 31, 1969, 06:00:00 PM by Guest »
\"People who sin say this: That they had to, to survive. People who sin say this: That it\'s too late to stop. The shadow called Sin dogs them steadily without saying a word. Remorse and Agony are repeated, to finally end up at Despair. But sinners don\'t know that if they turn around, there is a light.... a light which keeps shining on them ever so warmly.\" - Vash the Stampede - Trigun

\"There\'s a heaven on earth that so few ever find, though the map\'s in your soul and the road\'s in your mind. So many mountains before us, so many rivers to cross, where is the wisdom to bring back the vision we\'ve lost? Can we gaze with the wonder of children into the deafening night? Has it gotten so dark that you cannot remember the light?\" - D. Fogelburg


Xorlak

  • Administrator
  • Member
  • *****
  • Posts: 2225
    • View Profile
    • http://darkagegames.net
Re: MySQL
« Reply #2 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.
« Last Edit: December 31, 1969, 06:00:00 PM by Guest »

DarkElite

  • Member
  • *
  • Posts: 1452
    • View Profile
    • http://cryosoft.mysticsoftware.net/Home.html
Re: MySQL
« Reply #3 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...
« Last Edit: December 31, 1969, 06:00:00 PM by Guest »
DarkElite

Dei vobem omniam proditiverunt.  Iam vobis quis deposcibitis sacrificium rersum vitae est!

Michael J. Hill

  • Member
  • *
  • Posts: 244
    • View Profile
    • http://ls.mysticsoftware.net/
Re: MySQL
« Reply #4 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.
« Last Edit: December 31, 1969, 06:00:00 PM by Guest »
\"People who sin say this: That they had to, to survive. People who sin say this: That it\'s too late to stop. The shadow called Sin dogs them steadily without saying a word. Remorse and Agony are repeated, to finally end up at Despair. But sinners don\'t know that if they turn around, there is a light.... a light which keeps shining on them ever so warmly.\" - Vash the Stampede - Trigun

\"There\'s a heaven on earth that so few ever find, though the map\'s in your soul and the road\'s in your mind. So many mountains before us, so many rivers to cross, where is the wisdom to bring back the vision we\'ve lost? Can we gaze with the wonder of children into the deafening night? Has it gotten so dark that you cannot remember the light?\" - D. Fogelburg


drcrazy4

  • Member
  • *
  • Posts: 43
    • View Profile
Re: MySQL
« Reply #5 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.
« Last Edit: December 31, 1969, 06:00:00 PM by drcrazy4 »

Michael J. Hill

  • Member
  • *
  • Posts: 244
    • View Profile
    • http://ls.mysticsoftware.net/
Re: MySQL
« Reply #6 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.
« Last Edit: December 31, 1969, 06:00:00 PM by Guest »
\"People who sin say this: That they had to, to survive. People who sin say this: That it\'s too late to stop. The shadow called Sin dogs them steadily without saying a word. Remorse and Agony are repeated, to finally end up at Despair. But sinners don\'t know that if they turn around, there is a light.... a light which keeps shining on them ever so warmly.\" - Vash the Stampede - Trigun

\"There\'s a heaven on earth that so few ever find, though the map\'s in your soul and the road\'s in your mind. So many mountains before us, so many rivers to cross, where is the wisdom to bring back the vision we\'ve lost? Can we gaze with the wonder of children into the deafening night? Has it gotten so dark that you cannot remember the light?\" - D. Fogelburg


drcrazy4

  • Member
  • *
  • Posts: 43
    • View Profile
Re: MySQL
« Reply #7 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.
« Last Edit: December 31, 1969, 06:00:00 PM by Guest »