0

I have authorized my google compute VM's static ipaddress for the cloud sql instance.

I can connect to the cloud sql instance using a mysql client on my compute VM but when I am running a php script on the compute VM it fails on the mysqli create connection call with a 500 error saying cannot load resource (console error)

Any help is appreciated. Thanks.

  • Can you please post the whole error? What resource? Are you able to connect to any other MySQL instance? – orhtej2 Oct 06 '17 at 18:22
  • test.php Failed to load resource: the server responded with a status of 500 (Internal Server Error). Here is the script with the connection details changed:echo "step 200"; $conn = new mysqli("99.999.999.100", "user", "password", "DBname"); if($conn->connect_errno) { echo 'Database connection failed...' . 'Error: ' . $conn->connect_errno . ' ' . $conn->connect_error; exit; } else { $conn->set_charset('utf8'); } echo "Just after conn"; I dont see any other error being display in the browser console and I dont see the echo just after conn displayed on the plage – Vijay Pawar Oct 06 '17 at 18:45
  • Can you please provide detailed php error log? Something like https://stackoverflow.com/a/21429652/7034621 – orhtej2 Oct 06 '17 at 18:49
  • 1
    I believe you may have mysqli misconfigured, hence I asked if you're able to connect to any other MySQL database. – orhtej2 Oct 06 '17 at 18:50
  • I can connect to the same google cloud sql instance using a mysql client on the compute vm successfully – Vijay Pawar Oct 06 '17 at 18:50
  • I'm talking about the php library, the fact you can connect with client apps rules out general connectivity issue/database instance issue. – orhtej2 Oct 06 '17 at 18:51
  • Thanks for the pointers, I added the error ini in the script and here is the error it shows now Fatal error: Class 'mysqli' not found in /var/www/html/test.php on line 37 – Vijay Pawar Oct 06 '17 at 18:54
  • Perhaps this might help: https://stackoverflow.com/a/7250437/7034621 – orhtej2 Oct 06 '17 at 19:03
  • 1
    Thank you so much. I did a yum update and then an apache restart which solved this issue. – Vijay Pawar Oct 06 '17 at 19:17

0 Answers0