I don't know if this is relevant in anyway but here goes: I had a script working fine called insert.php and so I then moved onto creating a script that could delete rows. after some testing I noticed the script i was using was connecting to the database but then seemed unable to make any changes. I then ran the MySQL query in phpmyadmin to check it was valid and it worked. I then went back to my insert.php script and that had stopped working too. I then looked at my index.php page and that was inserting the database just fine. Does anyone have the foggiest what might be happening here? I must stress that it 1000% isn't a connection issue
index page which pulls information from the server (this is at the top of the document:
<?php
$con=mysqli_connect("localhost","root","xxx","xxx");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
Connection within insert.php
$dsn = 'mysql:host=localhost;dbname=GLO12408958DB';
$username = 'root';
$password = 'xxx';
//
// DB connection was made
//
try{
$pdo = new PDO($dsn, $username, $password,
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
die(json_encode(array('outcome' => true)));
}
catch(PDOException $ex){
die(json_encode(array('outcome' => false, 'message' => 'Unable to connect')));
}
connection within delete.php:
<?php
$con=mysqli_connect("localhost","root","xxx","glo12408958db");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
A few things (the first is probably your problem...):
GLO12408958DB
is not the same as glo12408958db
. Unless you are hosting on windows or a mac...die()
statement after you open your PDO connection. Is that just for debugging or is that really there? If it is, remove it.