Ah, I wasn't using mysqli_error() correctly, but I think I am now and it's still not outputting anything.
error_reporting(E_ALL);
include("dataInfo.php");
$connect = mysqli_connect($host,$account,$password);
if ($connect) {
echo "Connected to server<br>";
} else {
echo "Server connection error<br>";
}
$db = mysqli_select_db($connect,$dbname);
if ($db) {
echo "Connected to database<br>";
} else {
echo "Database connection error<br>";
}
$testa = 3;
$testb = 7;
$sql = "INSERT INTO testTable (testa,testb) VALUES ($testa,$testb)";
$result = mysqli_query($sql);
if ($result) {
echo "Insert successful";
} else {
echo "Insert error - ";
echo mysqli_error($connect);
}
mysql_close($connect);
As far as the type specific variables, according to the book I've been learning PHP out of, strings get quotes around them, and integers don't. For example, if I was inputting strings, I would type the $sql string as so:
$sql = "INSERT INTO testTable (testa,testb) VALUES ('$testa','$testb')";
I've gone into the database control panel and inserted the query manually, and that works, so there's nothing wrong with "INSERT INTO testTable (testa,testb) VALUES (7,3)". It seems the problem has to be with the $testa and $testb variables, or with sending the query. If it's not either, it has to be something on the database side...do databases have permission settings? :queasy:
As far as the code you gave me, I messed around with it some, but I don't understand enough of it, and I can't even get it to give me an error report. I'm thinking about going through the hassle of setting up a PHP environment right on my computer just to get error reports when I need 'em, lol.
WOOT! I am so stupid...all I had to do was read the book closer.
$result = mysqli_query($sql);
...should have been...
$result = mysqli_query($connect,$sql);
AND IT WORKS!
Sorry about the double post, but I can't find any edit button around here...