CodeLobster IDE
http://codelobster.com/forum/

update database
http://codelobster.com/forum/viewtopic.php?f=3&t=24758
Page 1 of 1

Author:  12Strings [ Thu Mar 12, 2020 1:34 am ]
Post subject:  update database

[b][/Hi,someone tell what's wrong with this code
Code:
      <?php
// error_reporting(0);
error_reporting(E_ALL ^ E_NOTICE);
require 'homedb-connect.php';

            $id = $_POST['id'];                   
            $target = $_POST['target'];
            $email = $_POST['email'];
            $visits = $_POST['visits'];
            $lastused = $_POST['lastused'];
            $saved = $_POST['saved'];
           
           
            $sql = "UPDATE lookuptbl ". "SET visits = visits+1, lastused = (NOW);
saved = "y".
               "WHERE date = '0000-00-00'" ;
            mysqli_select_db('homedb');
            $retval = mysql_query( $sql, $conn );
           
            if(! $retval ) {die('Could not update data: ' . mysql_error());}
            echo "Updated data successfully\n";           
            mysql_close($conn);
         
            ?>
b]

Author:  Admin [ Tue Mar 24, 2020 2:32 pm ]
Post subject:  Re: update database

Hi.

You have a syntax error in your SQL query (; instead of .)

It should be:

Code:
$sql = "UPDATE lookuptbl ". "SET visits = visits+1, lastused = (NOW)".
"saved = 'y'".
               "WHERE date = '0000-00-00'" ;

Regards,
Codelobster Team.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/