Connection to existing database
Hello,
I'm trying to make a connection to the database of the company that i'm working for currently as a intern.
This is the code that i used for it but i'm getting the error: Parse error: syntax error, unexpected '$conn' (T_VARIABLE)
<?php
$servername = "******************";
$username = "*********";
$password = "*********";
$dbname = "*********";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO testomgevingplugin_horsemanager_horses (id, external_id, name,)
VALUES (9089, '9', 'paard')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
i'm trying to fill the database tables with data with this php code. I know i can do this in mysql but i need it in code for a program. (its info about some horses).
But it won't work so far.
Does anyone know what i can do now?
Maby i got the wrong info at $servername? but i don't know for sure where i can find the servername. Or is there a problem with this code.
I'm new to php/mysql.
Greetings,
Geert
Subject
Written By
Posted
Connection to existing database
November 06, 2019 02:20AM
November 06, 2019 06:19AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.