I know that this is same with a lot of other posts here but i can't figure it out!
my code looks like this:
$i=0;
$shelves = array();
$shelves['position'] = array();
$query = "select id, cat_id, book_title, writer, publisher, issue_year, copies, abstract from library where $table like '%$search_param%'";
$result = mysql_query($query);
while ( $data = mysql_fetch_assoc($result) ) {
error_log($data['id']);
$shelves['position'][$i]['id'] = $data['id'];
$shelves['position'][$i]['cat_id'] = $data['cat_id'];
$shelves['position'][$i]['book_title'] = $data['book_title'];
$shelves['position'][$i]['writer'] = $data['writer'];
$shelves['position'][$i]['publisher'] = $data['publisher'];
$shelves['position'][$i]['issue_year'] = $data['issue_year'];
$shelves['position'][$i]['copies'] = $data['copies'];
$shelves['position'][$i]['abstract'] = $data['abstract'];
++$i;
}
error_log( count($shelves['position']) );
And because there are tones of other posts like this one i tried their solution:
$query = sprintf("select id, cat_id, book_title, writer, publisher, issue_year, copies, abstract from library where %s like'%%%s%'",mysql_real_escape_string($table),mysql_real_escape_string($search_param) );
Or Something like that:
$query = "select id, cat_id, book_title, writer, publisher, issue_year, copies, abstract from library where $table like '%{$search_param}%'";
I also tried run the query without dynamic variables just text and i got the same thing.
$query = "select id, cat_id, book_title, writer, publisher, issue_year, copies, abstract from library where book_title like '%lord%'";
Nothing seems to work.
I've tested my query on mysql workbench and it works like a charm!
In all of three queries i never get a log of the first error_log and the second one yells at me 0 every time!
Could someone light the way please?
mysql_query($query) or die(mysql_error();so we can see if there is any error.