aneeb Posted October 8, 2012 Share Posted October 8, 2012 Hey everyone! i am having some problem. In my code i am fetching data from multiple tables, but the code is having some problem it give me "mysql_fetch_array() expects parameter 1 to be resource, boolean given " error ... here is my code <?php$localhost="localhost";$dbuser="root";$dbpass="";$dbname="shoppro";$connect=mysql_connect($localhost,$dbuser,$dbpass);if ( !$connect ){echo "Error connecting to database.\n";}mysql_select_db("$dbname",$connect);$count = "select count(*)-1 from core_store_group";$i = '';$sql = '';for($i=0;$i<$count;$i++){$sql = "select name,price,short_description,sku,weight,promotion from catalog_product_flat_'".$i."'". "UNION ALL";}$query=$sql.substr(0,$sql.strlen($sql)-9);$result=mysql_query($query);while($row=mysql_fetch_array($result)){echo $row['name'];}?> please help me !! Link to comment Share on other sites More sharing options...
niche Posted October 8, 2012 Share Posted October 8, 2012 (edited) Where's your ref to mult tables in your code? http://w3schools.com/sql/sql_join.asp Edited October 8, 2012 by niche Link to comment Share on other sites More sharing options...
Ingolme Posted October 8, 2012 Share Posted October 8, 2012 We do have a thread concerning your issue: http://w3schools.inv...showtopic=44106 Another problem seems to be the misuse of the $count variable here: $count = "select count(*)-1 from core_store_group";$i = '';$sql = '';for($i=0;$i<$count;$i++){ Link to comment Share on other sites More sharing options...
oldscholar Posted October 12, 2012 Share Posted October 12, 2012 $i = 1;$sql = "select name,price,short_description,sku,weight,promotion from catalog_product_flat_'".$i."'". "UNION ALL";$query=$sql.substr(0,$sql.strlen($sql)-9);echo $query;//It seems you have problesm with the concatenation of values in the variable $query. Please inspect it again. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now