Jump to content

Unable to update MYSQL with PHP


gilgimech

Recommended Posts

Not sure if this should go in this area or MYSQL. If it's in the wrong section, sorry.

 

I cannot update my myqsl database the form I created.

 

the form


<!DOCTYPE html>
<html>
   <head></head>
   <body>
      <form action="../includes/maintenance_on_off2.php" method="$_POST">
<select name="maintonoff">
<option  value="" selected="selected">Select a On/Off</option>
<option value="0">Off</option>
<option value="1">On</option>
</select>
         <input type="submit" name="submit" value="Submit" />
      </form>
   </body>

</html>

 

 

This is the maintenance_on_off2.php script


<?php
$maint_on_off = $_REQUEST['maintonoff'];

$hostname="localhost"; 
$username="user"; 
$password="pass"; 
$database="database";
$tbl_name="table";

// Connect to the database 
MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect"); 
@MYSQL_SELECT_DB("$database") OR DIE("Unable to select database");

$query="UPDATE $tbl_name SET on_off='$maint_on_off'"; 

if ($checkresult) echo '<p>update query succeeded'; 
else echo '<p>update query failed';

echo $on_off;
mysql_close();
?>

 

Sometimes it'll echo "update query succeed' and echo the $on_off value, but it won't update the database.

Most of the time it'll fails. It seem kinda random if it succeeds or fails.

 

Link to comment
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.