Question : PHP Updating Databases error handling.

i wrote this code to code to update a database, . the error im getting is

Warning: mysqli_query() expects parameter 1 to be mysqli,

it is refering to this line. but i dont see what the problem is.

$queryResult = mysqli_query($con,$queryString);

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
<?php

$Milg = $_POST[mileage];
$NMilg = $_POST[Nmileage];
$Mdl=$_POST[model];
$Mke=$_POST[make];

$con = mysql_connect("localhost","phpuser","phppass");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("my_cars", $con);

$queryString="UPDATE Cars SET Mileage = '$NMilg'
WHERE Model = '$Mdl' AND Make = '$Mke' AND Mileage ='$Milg'";

$queryResult = mysqli_query($con,$queryString);
  		    if ($queryResult) {
            echo "Car <b>$Mke $Mdl</b> been updated";
		      } else {
			     ?>
             Car not found
            <form action="update.php" method="post"><br>
	    Make: <input name="make" type="text"/><br>
	    Model: <input name="model" type="text"/><br>
	Old	Mileage: <input name="mileage" type="text"/><br>
	New Mileage:<input name="Nmileage" type="text"/><br>
	    <input type="Submit" value="Update" />
	           
	          </form>
			  <?php
}
mysql_close($con);
?>

Answer : PHP Updating Databases error handling.

Oops, I should have caught that, you had it backwards.  Should be "mysql_query($queryString,$con)" .
Random Solutions  
 
programming4us programming4us