MYSQL variable In php query -
i trying query multiple mysql statement in 1 query failed.
$testq =""; $testq .= mysql_query("set @@group_concat_max_len = 5000"); $testq .= mysql_query("set @sql = null"); $testq .= mysql_query("select group_concat(distinct concat( 'max(if(property_name = ''', property_name, ''', value, null)) ', property_name ) ) @sql properties"); $testq .= mysql_query("set @sql = concat('select item_id, ', @sql, ' properties group item_id')"); $testq .= mysql_query("prepare stmt @sql"); $testq .= mysql_query("execute stmt"); $da = mysql_query($testq, $dbconnect); while($rt = mysql_fetch_assoc($da){ //print }
error is: warning: mysql_fetch_assoc() expects parameter 1 resource, boolean given in c:\users.....on line 24 how can query , print result in table?
the mysql extension in php not support multi queries in php security reasons mysql_query
. should not use mysql anymore furthermore, use mysqli.
you should use union or concat queries. if want make multi query, should use mysqli_multi_query
within mysqli library.
then syntax have another. queries have submitted 1 string in 1 function this:
$mysqli->multi_query("select * table; truncate table; drop table;");
Comments
Post a Comment