Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.