0

I have a problem executing mysqli from magento. I need it to query an external db and retrive tracking information.

I added this code to a php plugin file:

$conn = new mysqli($db_server, $db_user, $db_pass, $db_name);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
                        }

$sql = "SELECT `label_url` FROM tracking WHERE `tracking_carrier` = 'BRT' AND `tracking_number` = '$trackingNumber';";
$result = $conn->query($sql); ```

but when loading the page i got a 500 erro.

I then opened the php log and found

```PHP Fatal error:  Uncaught Error: Class 'Plugin\Order\mysqli```


It looks like i cannot use **mysqli**

Is there any other way to query an external db with a mysql query?

1 Answer 1

0

I solved just adding a backslash in front of the msqli

$conn = new \mysqli($db_server, $db_user, $db_pass, $db_name);

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.