0

this is my database

prod - id, title, code

uname - id, email, name, code

======== edited ============

problem:

When I use [email protected] I always got response 1 - which mean it worked

When I use [email protected] I'm able to add the same product over and over again and always got response 2 - which means something is wrong.

Any idea?

Thanks

edit == just fix the code and paste it once more. I have no syntax error.

edit again.

It's working now with some sql modification. First try using PHP had to study more.. Can't mention ur name one by one.. But again, Thank you!

joe
  • 1
  • 1

3 Answers3

2

What @nick rulez said is true, you forgot the $ sign.

edit: However, mysql_fetch_array will ALSO return results such as:

Array(
[0] => '[email protected]'
[1] => 'name'
);

you should try using mysql_fetch_assoc, which will produce an array with the keys you're looking for.

Array(
[**email**] => '[email protected]'
[name] => 'name'
);

Cheers!

bstpierre
  • 30,042
  • 15
  • 70
  • 103
fsodano
  • 548
  • 2
  • 8
  • mysql_fetch_array by default produces a combo array/hash structure, unless you specifically request only one of the two types. – Marc B Mar 24 '11 at 14:22
  • You are right, apologies. Nevertheless, it might be more efficient to just fetch the associative array, based on the code extract @joe posted. Cheers! – fsodano Mar 24 '11 at 14:51
0

if you compare 0 int value to a string value that is not a number the result will always be true

if(0 == "Hello") -> true

because the downcast from string to int returns true (0) and 0 == 0 always true

EDIT: okay yeah you only missed the $ -.-

sharpner
  • 3,857
  • 3
  • 19
  • 28
0

What is this supposed to do?

if (user2 == "email")

You need a $ before user, and "email" should be $email, right?

Also, the code is ripe for sql injections. Escape all input variables with mysql_real_escape_string before you put them into queries (for more info: Protect against SQL injection).

Community
  • 1
  • 1
Jon
  • 428,835
  • 81
  • 738
  • 806