I have three databases in the same server.. They are margoplatinum, detos and plaza.
They also have the same structure of tables. One of the table is called movie.
Here is the table structure of movie table:
id_movie int(11) PK, AI;
movie_title varchar(100);
status varchar(30);
Data from margoplatinum in movie table are:
id_movie | movie_tittle | status
--------------------------------------------------
1 | Frozen | Now Playing
2 | The-Amazing-Spidey2 | Coming Soon
Data from detos in movie table are :
id_movie | movie_tittle | status
--------------------------------------------------
1 | Comic8 | Now Playing
2 | Godzilla | Coming Soon
and data from plaza in movie table are :
id_movie | movie_tittle | status
--------------------------------------------------
1 | The Killer | Now Playing
2 | Godzilla | Coming Soon
So what i want to do is to select from the three databases above (in my php code and convert it into JSON) for table movie where the status = "Now Playing"..
Here is my php code :
<?php
$db_host = "127.0.0.1";
$db_uid = "root";
$db_pass = "";
$db_con = mysql_connect($db_host,$db_uid,$db_pass) or die('could not connect');
$q = mysql_query('SELECT DISTINCT a.id_movie, b.id_movie, c.id_movie, a.movie_tittle,
b.movie_tittle, c.movie_tittle FROM `margoplatinum`.movie a
INNER JOIN `detos`.movie b ON a.id_movie = b.id_movie
INNER JOIN `plaza`.movie c ON b.id_movie = c.id_movie
WHERE a.status = "Now Playing"');
$v = '{"info" : [';
while($r=mysql_fetch_array($q))
{
$ob = array("<br>","<b>","</b>");
if(strlen($v)<12)
{
$v .= '{"id_movie" : "'.$r['id_movie'].'", "movie_tittle" :
"'.$r['movie_tittle'].'"}';
}
else
{
$v .= ',{"id_movie" : "'.$r['id_movie'].'", "movie_tittle" :
"'.$r['movie_tittle'].'"}';
}
}
$v .= ']}';
echo $v;
echo mysql_error();
mysql_close();
?>
But when I execute the php above, an error occured..Here is the error message :
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\CinemaInfo\list_movie.php on line 17
{"info" : []}Unknown column 'a.status' in 'where clause'
Is my query above correct? or i did something wrong with my query.. Can anyone help me to write the correct query based on my case above? I really appreciate any help from you. Thank you :)