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());

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...

Recommended Answers

All 3 Replies

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.

thanks, got it to working and yea i going to start using pdo now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.