First ever PHP/MySQL script not working.
Posted: Fri Dec 05, 2008 3:27 am
Hi everyone, I just started learning php like last week and tried typing out my first ever piece of code involving MySQL (I've done HTML before) and though it's such a simple code, I can't seem to find the problem. I've already included all the error reporting stuff but when I try to run this piece of code nothing comes up and nothing appears in my MySQL databases when I try the SELECT query.
I'm sorry to bother everyone with such simple code, but I've been fretting over nothing but this for the past few hours and really need someone to advise me.
Thanks in advance.
Code: Select all
<html>
<body>
<?php
error_reporting(E_ALL);
$host = "localhost";
$user = "root";
$password = "password";
$db = "test";
$cxn = mysqli_connect($host,$user,$password,$db) or die(mysql_error());
$sql = "insert into posts (Title,Content) values ("test","test")";
$result = mysqli_query($cxn,$sql) or die(mysql_error());
var_dump($result);
?>
</body>
</html>
Thanks in advance.