this works fine

$view_query = mysql_query("SELECT ip_address FROM view");

but this query below give me a error

$view_query = mysql_query("SELECT ip_address FROM view WHERE ip_address = $user_ip") or die(mysql_error());

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.0.1' at line 1

only reason it give my error bc of 'WHERE ...'. it looks good to me. i also connect to the database at to of page. mysql_connect...

5 Years
Discussion Span
Last Post by james.anthoney.716

Propably the ‘ip_address’ in your ‘view’ table is VARCHAR so you need to use quotes ( '$user_ip' ) . Besides that I would really recommend you to take the time to learn how to use prepared statements … PHP has the PDO data access interface which is great , really simple and the time that you will spent learning how to use it will pay off.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.