php - connection to google cloudsql -
im trying connect google cloudsql appengine, im facing error:
no connection made because target machine actively refused
my php file, have uploaded appengine:
$sql = new mysqli(null, 'myuser', // username 'mypass' 'mydb', null, '/cloudsql/**:**' ); if ($mysqli->connect_error) { echo 'no'; die('connect error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error); } else { echo 'yes\n'; }
the appengine allowed cloud sql. should ?
i have been trying replicate error getting unable reproduce when using code sample provided.
also code sample has few mistakes, create connection $sql check $mysqli connection errors, should checking $sql. have changed occurances of $mysqli $sql , more conventional way check connection error check connect_errno , read message connect_error
$sql = new mysqli(null, 'your-username', // username 'your_password_or_blank_if_using_root', 'database_name', null, '/cloudsql/project_id:instance_name' ); if ($sql->connect_errno) { echo 'no'; die('connect error (' . $sql->connect_errno . ') '. $sql->connect_error); } else { echo 'yes\n'; }
Comments
Post a Comment