Jump to content

insert query-help


wazza91

Recommended Posts

hi im trying to do a  insert query but i keep getting the error messeage ? mysql_error() expects parameter 1 to be resource, object given in /Users/garykane/Sites/update2.php on line 6

success in database entry.-1 row inserted?

 

here is my code

<?php

$con = mysqli_connect("localhost", "root", "") or die ("No connection"); /*connect to server*/ mysqli_select_db($con ,"Declan") or die ("db will not open"); /*connect to database*/ $dno = $_POST["dno"];

$dname = $_POST["dname"];

$location = $_POST["location"];

$query="Update INTO AccountNumber VALUES (" .$dno . ", '" . $dname . "','" . $location . "')"; if(!mysqli_query($con, $query)) echo mysql_error($con);

echo "success in database entry.";

$numrows = mysqli_affected_rows($con);

echo $numrows . " row inserted<br>";

mysqli_close($con);

?>

 

 

here is the front end texbox code

<html>

<head>

<title>Question 2, Accounts</title>

</head>

<h1>Enter Details</h1>

<body>

 

<form action="update2.php" method="post">

Account Number : <input type="text" name="dno" /><br />

Balance : <input type="text" name="dname" /><br />

Customer Name : <input type="text" name="location" /><br />

<input type="submit" name="submit" value="submit" />

</form>

 

<?php

$con = mysqli_connect("localhost", "root", "") or die ("No connection"); /*connect to server*/

mysqli_select_db($con ,"Declan") or die ("db will not open"); /*connect to database*/

?>

 

</body>

</html>

 

 

Link to comment
https://forums.phpfreaks.com/topic/239647-insert-query-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.