Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

mysqli update


  • Please log in to reply
No replies to this topic

#1 12Strings

12Strings

  • Members
  • 41 posts
  • OFFLINE
  •  
  • Local time:02:27 PM

Posted 19 June 2015 - 08:17 PM

Hi, I'm having some trouble updating a database using mysqli code and could use help. I get this error message:
 

Error updating record: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM testbl WHERE recur = 'Y' && payrec = 'P' && pd = ''' at line 6

 


Following is my code:
 

<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
$servername = "localhost";
$username = "root";
$password = "cookie";
$dbname = "test";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error)
    { die("Connection failed: " . $conn->connect_error); }
// -----------------------------------------------------------
        $recur = 'recur';
        $periodic = 'periodic';
    $pd = 'pd';
    $payrec = 'payrec';
        $duedate = 'duedate';
        $datepaid = 'datepaid';
        $dayslate = 'dayslate';                
// -------------------------------------------------------------
   if($periodic == 1)
   {$duedate = date('Y-m-d', strtotime('+4 week')) ."\n";}
   if($periodic == 6)
   {$duedate = date('Y-m-d', strtotime('+25 week')) ."\n";}
   $pd = 'P'; $dayslate = 0; 
   // -------------------------------------------------
 $sql = "UPDATE testbl SET
 duedate = '$duedate',
 pd = '$pd',
 dayslate = '$dayslate',
 datepaid = NOW()
FROM testbl WHERE recur = 'Y' && payrec = 'P' && pd = ''";
// ----------------------------------------------------------- 
if ($conn->query($sql) === TRUE)
    { echo "Record updated successfully"; }
 else
    { echo "Error updating record: " . $conn->error; }
$conn->close();
?>


BC AdBot (Login to Remove)

 


m



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users