mysql_query not inserting into database

#1

I’m trying to run an SQL statement that inserts client data into a database, however the row is not being inserted into the database.
[php]

<?php $mysql['con'] = mysqli_connect("xxxx", "xxxx", "xxxx", "xxxx"); ; $companyname = mysqli_real_escape_string($mysql['con'], $_POST['companyname']); $clientname = mysqli_real_escape_string($mysql['con'], $_POST['clientname']); $email = mysqli_real_escape_string($mysql['con'], $_POST['email']); $address = mysqli_real_escape_string($mysql['con'], $_POST['address']); $postcode = mysqli_real_escape_string($mysql['con'], $_POST['postcode']); $mobile = mysqli_real_escape_string($mysql['con'], $_POST['mobile']); $phone = mysqli_real_escape_string($mysql['con'], $_POST['phone']); $checkemail = mysqli_query($mysql['con'], "SELECT * FROM `clients` WHERE email='" . $email . "'"); if(mysqli_num_rows($checkemail) != 0) { echo "Error: Email already exists"; exit; } $query = mysqli_query($mysql['con'], "INSERT INTO `clients` (`clientname`, `companyname`, `email`, `address`, `postcode`, `mobile`, `phone`, `comment`) VALUES '" . $companyname . "', '" . $clientname . "', '" . $email . "', '" . $address . "', '" . $postcode . "', '" . $mobile . "', '" . $phone . "', 'No Comments.'"); if($query) { $checkemailtwo = mysqli_query("SELECT * FROM `clients` WHERE email='" . $email . "'"); while($rowtwo = mysqli_fetch_array($checkemailtwo)) { $idtwo = $rowtwo['id']; } header("Location: " . $siteindex . "viewjobs.php?client=" . $idtwo . "&update=1"); } else { echo "Something went wrong"; exit; } ?>

[/php]

Any help would be greatly appreciated.

#2

I don’t see anything wrong with your SQL, the only thing I can think of is that maybe you have auto committing turned off… and you have to run the

$mysqli->commit();

Command to actually commit the insert.