very lame problem

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Re: very lame problem

Post by seandisanti » Tue Apr 02, 2013 8:55 am

1) To save yourself some trouble, build your query first, and then execute it like...

Code: Select all

$sql = "SELECT field1,field2 FROM table WHERE field =" . $value;
$blah = mysql_query($sql);
 
because then when it's not performing as expected, you can add 'die($sql)' to get just the query, which usually gives away the issue immediately, or at least gives you a query to run in phpMyAdmin or mysql.
In this case it would show you that using double quotes for your $brand key and your query doesn't work well.

2) mysql_ functions are deprecated and will probably be removed completely from a version in the very near future. PDO is a better way to interact with your database, and it's easy, I promise. check out this short video for a quick crash course http://jream.com/learning/videos/php-oo ... o-examples

Post Reply

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest