Here is the warning:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /var/www/angga/fungsi/fungsi-halaman.php on line 133
line 133 is $k = mysql_fetch_array($kata);
function tag($tagi){
$teks = explode(" ",$tagi);
for($i=0;$i<count($teks);$i++):
$teks2 = safe($teks[$i]);
$kata = mysql_query("select * from `tag` where id=$teks2");
$k = mysql_fetch_array($kata);
echo "<a href=\"\">".$k['nama']."</a> ";
endfor;
}
I am calling like this:
tag($post['tag']);
And output is :
test jancuk surem insert null value function ignore varchar
original value from $post['tag'] is 1 2 3 4 5 6 7 8 9
I want to convert value from $post['tag'] and display it as name from tag table in my database
I was tried edit by add or die(mysql_error()); and warning is still out.
here warning when I add 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 '' at line 1
What's wrong with my code ?
edit 1 :
the problem is solve by add '' so now is like
$kata = mysql_query("select * from `tag` where id='$teks2'") or die(mysql_error());
the answer is from first comment in my question, but now is gone or edited?
here the safe()
function safe($value){
return mysql_real_escape_string($value);
}