0
<?php
include_once 'dbconnect.php';
$flds= "UPDATE OFFICE SET OADD02=? WHERE OFFNO=$OFFNO";
$stmt = $mysqli->prepare($flds);
$stmt->bind_param('s',$OADD02);
$stmt->execute();
$stmt->close();

I execute the above and at the bind_param it fails. My process is as such:

  • The user goes into the form to update the information (information is display via mysqli queries);
  • They click submit.

Initializing and populating $stmt works, however when I get to bind_param the page goes blank. Here is the URL: http://gccitech.com/iclub/office.php?ONO=4&ftype=m

Rubens
  • 14,478
  • 11
  • 63
  • 92

2 Answers2

0

Try to bind both parameters:

$flds= "UPDATE OFFICE SET OADD02=? WHERE OFFNO=?";
$stmt = $mysqli->prepare($flds);
$stmt->bind_param('ss',$OADD02, $OFFNO);

I presumed, that $OFFNO is a string. If it's an integer, use this:

$stmt->bind_param('si',$OADD02, $OFFNO);
user4035
  • 22,508
  • 11
  • 59
  • 94
0

After reading through this I have noticed a couple of things. You have required a file but there you have not declared $mysqli meaning that the connection string might not work.

Also have you done checks around it to see if there is any errors that are going to show up? Try this code to check for errors and you will have a better idea of what is going on

if ($sql = $mysqli->prepare($query)){
            $sql->bind_param("s",$OADD02);
            $sql->execute();
        } else {
            echo "Failed prepare statement" . $this->conn->error . $this->conn->error;
        }

This way you'll be able to print out the MySQL errors. Once you have done this put the errors up and I can try and help.

Also you have not declared $OFFNO meaning that the query won't properly execute either. If you declare the connection of both $mysqli and $OFFNO and make sure you do error checking using the if statement above you should be able to see why it isn't working.

Tom
  • 389
  • 2
  • 15