-3

How can I get the results?:

$check = mysql_query("select username, email, case
            when max(username = '$username') > 0 and max(email = '$email') > 0 then 'both'
            when max(username = '$username') > 0 then 'username'
            when max(email = '$email') > 0 then 'email'
            end
            from school_users
            WHERE username = '$username' or  email = '$email'") or die(mysql_error());

I need "username" or "email" or "both" when it exists. How do I receive these variables?

  • 1
    Have you checked http://php.net/mysql_query? – zerkms Feb 10 '13 at 21:15
  • 1
    You shouldn't use the `mysql_query` function because it's deprecated. Use `mysqli_query` instead. – Luka Feb 10 '13 at 21:17
  • 2
    This is probably the continuation of his other question: http://stackoverflow.com/questions/14800674/how-would-i-stop-multiple-emails-or-username. I think you need to learn to research a little bit before questioning here. – Mateus Schneiders Feb 10 '13 at 21:28

2 Answers2

1

You should use fetch functions. mysql_query() returns resource of data, for getting this data, you need to use either mysql-fetch_assoc or mysql_fetch_array.

As already mentioned, mysql_* functions are deprecated as of >PHP 5.5, and they are bad practice of using. You should learn about mysqli or PDO.

Resources: http://php.net/mysql_query

http://php.net/mysql_fetch_assoc

http://php.net/mysql_fetch_array

http://php.net/mysqli

http://php.net/pdo

Michael Arenzon
  • 541
  • 8
  • 16
0

Ok I think I understand what you are trying to do. You have alot more work than you think you do. What you need is template to work with so you can make it your own. The link below will allow you to create your own php API to communicate with a MySQL database in the manner you are talking about. It is step by step and he gives you the code to work with, all of it!

android login and registration with php mysql and sqlite

I used it and it it awesome, if you have any questions feel free to message me.

put the green check if this helps

Mark
  • 911
  • 13
  • 30