Re: [PHP] Been staring at the code for too long...

2009-01-10 Thread Jason Pruim


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 . '' .$line . '' . $file . '' .  
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



Re: [PHP] Been staring at the code for too long...

2009-01-10 Thread tedd

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);

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 . '' .$line . '' . $file . '' . 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.


It works for me.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Been staring at the code for too long...

2009-01-09 Thread Jason Pruim


On Jan 9, 2009, at 4:29 PM, Daniel Brown wrote:


On Fri, Jan 9, 2009 at 13:38, Jason Pruim  wrote:

Okay... So I know this is a stupid question...


   It sure is.


I'm going to rewrite the whole thing anyway... I think I can do it  
better/more efficient given the time to look at it.


I really need to do more programming more often...I get rusty to  
quickly :P



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



Re: [PHP] Been staring at the code for too long...

2009-01-09 Thread Daniel Brown
On Fri, Jan 9, 2009 at 13:38, Jason Pruim  wrote:
> Okay... So I know this is a stupid question...

It sure is.

-- 

daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: [PHP] Been staring at the code for too long...

2009-01-09 Thread Dan Shirah
>
>mysqli_stmt_prepare($stmt, "UPDATE database.table (
>FName, LName,  email, phone,
> url, record,
>subscribed, date,
>  IPAddress,  Business,
>Address1,  City,  State,
>  Zip,
>Coffee,  Meeting,
>  areaPlans)
>VALUES
> (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
>
>
> Warning: mysqli_stmt_bind_param() [function.mysqli-stmt-bind-param]:
> invalid object or resource mysqli_stmt in /public_html/purl/purlprocess.php
> on line 67
> 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 '( FName, LName,
> email, phone, url, recor' at line 1
>
> Am I just going crazy or is there something really wrong?
>
> Okay.. I'm done... First stupid question of the year... Only 3,349,587 more
> to go for the year! :P


I don't work with MySQL, but shouldn't the UPDATE syntax be something like
this:

mysqli_stmt_prepare($stmt, "UPDATE database.table SET
FName = ?,
LName = ?,
email = ?,
phone = ?
WHERE id = ?");


[PHP] Been staring at the code for too long...

2009-01-09 Thread Jason Pruim
Okay... So I know this is a stupid question... But I've been staring  
at my code for far too long and now it's still not working so I  
thought I would show it to all of you and see if you can tell me  
where I'm being stupid :)


this is dbmysqliconnect.php:
function dbmysqliconnect($server, $username, $password,  
$database, $link) {

$link = mysqli_init();
mysqli_real_connect($link, $server, $username,  
$password, $database) or die('could not connect:  
'.mysqli_connect_error());



if (mysqli_connect_errno($link)) {
printf("Connect failed: %s\n",  
mysqli_connect_error($link));

exit();
}

return $link;
}
?>

this is a snipet of my index.php file:

$link = dbmysqliconnect($server, $username, $password,  
$database, $link);





//Do NOT insert or update sales rep database through this  
method... Only included to be supplied to the notify_email function. JP

$salesRepID = $_POST['salesRepID'];

$stmt = mysqli_stmt_init($link);

//Create the statement

mysqli_stmt_prepare($stmt, "UPDATE database.table (
FName, LName,   
email, phone, url, record,
subscribed, date,   
IPAddress,  Business,
Address1,  City,   
State,  Zip,
Coffee,  Meeting,   
areaPlans)
VALUES  
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");


// Error checking. JP

echo "Print of post:";
print_R($_POST);
echo "dump of the statement:";
var_dump($stmt);



mysqli_stmt_bind_param($stmt, 's',
   $_POST 
['txtFName'], $_POST['txtLName'], _POST['txtEmail'], $_POST 
['txtPhone'], $_POST['txturl'], $_POST['record'],
   $_POST 
['subscribed'], $date,  $_SERVER['REMOTE_ADDR'],  $_POST['txtBusiness'],
   $_POST 
['txtAddress1'], $_POST['txtCity'],  $_POST['txtState'],  _POST 
['txtZip'],
   $_POST 
['rdoCoffee'],  $_POST['rdoTime'],  $_POST['areaPlans'])

or 
die(mysqli_error($link)); 

The error that I am getting is:

Warning: mysqli_stmt_bind_param() [function.mysqli-stmt-bind-param]:  
invalid object or resource mysqli_stmt in /public_html/purl/ 
purlprocess.php on line 67
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 '( FName, LName, email, phone, url, recor' at line 1


Am I just going crazy or is there something really wrong?

Okay.. I'm done... First stupid question of the year... Only  
3,349,587 more to go for the year! :P




--
Jason Pruim
japr...@raoset.com
616.399.2355