Jump to content

MySQL query


bleed
 Share

Recommended Posts

I`m using this peiece of code I have found here on the forums. I have a problem trying to get these queries into only one, because I`m getting "out of syn`c" error message when I`m trying to run it.

Any ideas?

#include <array.au3>
#include "mysql.au3"

_MySQL_InitLibrary()
If @error Then Exit MsgBox(0, '', "")
$MysqlConn = _MySQL_Init()

$connected = _MySQL_Real_Connect($MysqlConn, "www.test.com", "DBusername", "DBpassword", "database")
If $connected = 0 Then Exit MsgBox(16, 'Connection Error', _MySQL_Error($MysqlConn))

$uname = 'testuser2'
$email = 'testuser2@test.com'
;"SELECT userid FROM profiles WHERE userid=(SELECT userid FROM users WHERE username=username)"
$uid = "SELECT userid FROM user WHERE username='" & _MySQL_Real_Escape_String($MysqlConn,$uname) &"'"
$substatus = "SELECT * FROM subscriptionlog  WHERE userid='" & _MySQL_Real_Escape_String($MysqlConn,$uid) & "' AND status='" & _MySQL_Real_Escape_String($MysqlConn,"1") & "'"
$query = "SELECT * FROM user WHERE username='"  & _MySQL_Real_Escape_String($MysqlConn,$uname) & "' AND email='" & _MySQL_Real_Escape_String($MysqlConn,$email) & "' AND status ='" & _MySQL_Real_Escape_String($MysqlConn,$substatus) & "'"
;$query = "SELECT * FROM user WHERE username='"  & _MySQL_Real_Escape_String($MysqlConn,$uid) & "' AND email='" & _MySQL_Real_Escape_String($MysqlConn,$email) 
MsgBox(0, '', $uid)
If _MySQL_Real_Query($MysqlConn, $uid) = $MYSQL_ERROR Then
    MsgBox(0, 'Error', _MySQL_Error($MysqlConn))
EndIf
If _MySQL_Real_Query($MysqlConn, $substatus) = $MYSQL_ERROR Then
    MsgBox(0, 'Error', _MySQL_Error($MysqlConn))
EndIf
If _MySQL_Real_Query($MysqlConn, $query) = $MYSQL_ERROR Then
    MsgBox(0, 'Error', _MySQL_Error($MysqlConn))
Else

;------------------------------------------------------


;------------------------------------------------------

$res = _MySQL_Store_Result($MysqlConn)
$users = _MySQL_Num_Rows($res)
if $users == 1 then
MsgBox(0, '', "Account Found Login OK!")
Else
   MsgBox(0,'',"Login Failed Either your ID and PW is wrong or your subscription has expired.");what to do if the UN and PW is not found
EndIf
_MySQL_Free_Result($res)
EndIf
_MySQL_Close($MysqlConn)
_MySQL_EndLibrary()
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...