Re: Been staring at the code for too long...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Jan 10, 2009, at 8:35 AM, tedd wrote:

At 1:38 PM -0500 1/9/09, Jason Pruim wrote:

       mysqli_stmt_prepare($stmt, "UPDATE database.table (

Jason:

Here's the problem, your code should read:

mysqli_stmt_prepare($stmt, "UPDATE database.table SET (

You forgot the "SET".

As a point of practice, I always use:

$query = "UPDATE $db_table SET first = '$first', second = '$second' WHERE id = '$id' ";

and then use the $query, such as:

mysqli_stmt_prepare($stmt, $query);

Hey tedd,

I hadn't done a update in a prepared statement before... and it was something I set up quite awhile ago... I ended up rewriting it just to refresh my mind on how it was working :)




I know every one has their own way, but also consider the following code:

--- code ---

$result = mysql_query($query) or die(report($query,__LINE__ ,__FILE__));

// with an accompanying function of:

//====================  show dB errors  ======================

function report($query, $line, $file)
  {
echo($query . '<br>' .$line . '<br/>' . $file . '<br/>' . mysql_error());
  }

--- end of code ---

This will:

1. Allow you to see your errors in more detail during development;

2. After the development, you have only to comment out one line of code (the echo) to stop reporting dB errors project-wide.

I really need to start doing that... Then I can track down the issues easier hopefully... :)



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux