i have data in one of my website and i want to print these data in other site.these two are in same server.at present i have to export mysql data and import into other then do this code to insert in 2nd domain.
i want to link directly so that i can make data request from 1st website and show in 2nd website.
i know for this to happen i need to enable bind-address = 127.0.0.1 to ip address of server and i have changed this
after that in first website i have granted the permission for that table using this command
GRANT select ON `database-name.tableA`.* TO 'userB'@'localhost';
but when i run i am getting this error
Failed to connect to MySQL: Access denied for user 'userA'@'localhost' to database 'database-name.tableA'
the code i am running from website B
here is my code.
databaseconnect.php
<?php
$con=mysqli_connect("localhost","UserA","passwordA","databaseA");
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
main.php
<?
include('/home/website2/public_html/databaseconnect.php');
$res2 = $con->query("SELECT * FROM `website1_tableA` where status='0' order by id asc limit 5");
while($result = $res2->fetch_assoc()){
$cont=$result['content'];
$tit=$result['title'];
echo $cont;
}
?>
Aucun commentaire:
Enregistrer un commentaire