[PHP] Re: Problem with function

2008-09-12 Thread Nathan Rixham

Jason Pruim wrote:
So, I am fighting with a problem function... I have used this function 
on a previous project and it worked just fine, so I'm not sure what 
changed...


The only difference is that on this site, I'm using mod_rewrite to write 
all non-existent folder requests into a php file to process what to do 
with it.


here's some code:

processing file:

?PHP
require(php.ini.php);
require(dbmysqliconnect.php);
require(defaults.php);
require(notify_email.php);
$link = dbmysqliconnect($server, $username, $password, $database, 
$link);

$date = time();


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

$salesRepID = $_POST['txtSalesRepID'];
$Record= $_POST['txtRecord'];
notify_email($Record, $salesRepID);
$stmt = mysqli_stmt_init($link);

//Create the statement


mysqli_stmt_prepare($stmt, UPDATE purl.schreur SET
FName = ?,
LName = ?,
email = ?,
phone = ?,
record = ?,
subscribed = ?,
date = ?,
IPAddress = ?,
Business = ?,
Address1 = ?,
City = ?,
State = ?,
Zip = ?,
Coffee = ?,
Meeting = ?,
time = ?)
or die(prepare error  . mysqli_error($link));


mysqli_stmt_bind_param($stmt, '',
   $_POST['txtFName'],
   $_POST['txtLName'],
   $_POST['txtEmail'],
   $_POST['txtPhone'],
   $_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( bind error  . mysqli_error($link));
//Add the record
mysqli_stmt_execute($stmt) or die( execute error  . 
mysqli_error($link));


?


notify_email.php file:

?PHP

function notify_email($Record, $salesRepID) {

require(defaults.php);
require(func.sendemail.php);
require(dbmysqliconnect.php);
$salesRep = array(1 = [EMAIL PROTECTED], 
[EMAIL PROTECTED], 2 = [EMAIL PROTECTED], 
[EMAIL PROTECTED], 3 =[EMAIL PROTECTED], 
4=[EMAIL PROTECTED]);

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

echo 2;
$sql = SELECT * FROM schreur WHERE record='{$Record}';
$row[] = mysqli_query($link1, $sql) or die(Could not perform 
query: .mysqli_errno($link1));

echo 3;
$result = $row[0];
echo 4;

   
//$dataSet = array();
   
//while ($row = mysqli_fetch_assoc($result)) {

//echo brwhileBR;
//$dataSet[] = $row;

//}

$from= [EMAIL PROTECTED];
echo 5;
$returnPath = [EMAIL PROTECTED];
$replyTo = [EMAIL PROTECTED];
echo $Record;
echo 6;
//echo brJust before while in notify_email.phpbr;
   
//echo brdirectly above whilebr;
   
//echo BRdataset print: ;

//print_r($dataSet);
//echo BR;
//echo brdirectly above foreachbr;
//foreach ( $dataSet AS $row ) {
echo 6;
while ($row = mysqli_fetch_assoc($result)) {   
echo inside while;

//Build the e-mail headers
$ID = $row['salesRep'];
$to = $salesRep[$ID];
$headers = From: .$from.\n;
$headers .= Return-Path: .$returnPath.\n;
$headers .= Reply-To: .$replyTo.\n;
   
$subject = {$row['FName']} wants coffee!;
   
$message = First Name: {$row['FName']} \n;

$message .= Last Name: {$row['LName']}\n;
$message .= Company  . $row['Business'] . \n;
$message .= Email: .$row['email'] . \n;
$message .= Phone:  .$row['phone'] . \n;
$message .= Address:  . $row['Address1'] . \n;
$message .= City:  . $row['City'] . \n;
$message .= State:  .$row['State'] . \n;
$message .= Zip: . $row['Zip'] . \n;
$message .= Coffee of choice: .$row['Coffee'] . \n\n;
$message .= When a good time would be: \n.$row['Meeting'] 
. \n\n;

$message .= Current plans: \n\n;

Re: [PHP] Re: Problem with function

2008-09-12 Thread Jason Pruim


On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote:


Jason Pruim wrote:



nothing obvious to me.. so debug more!

?PHP

   function notify_email($Record, $salesRepID) {
echo in notify_email . PHP_EOL;
   require(defaults.php);
echo already loaded and required defaults loaded . PHP_EOL;
   require(func.sendemail.php);
echo require func.sendemail.php loaded . PHP_EOL;
   require(dbmysqliconnect.php);
echo already loaded and required dbmysqliconnect loaded . PHP_EOL;

will tell you where it's breaking I'd assume..


Okay, when I had that in the notify_email.php file it looked like it  
all loaded just fine... the echo's were displayed.


When I put that in my process.php file I got this output:
already loaded and required defaults loaded Just before send_email  
functionjust after send_email funtion

require func.sendemail.php loaded
already loaded and required dbmysqliconnect loaded
execute error Duplicate entry '0' for key 1

So I think Jochem might be right... Problem with mysqli?


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]





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



Re: [PHP] Re: Problem with function

2008-09-12 Thread Jason Pruim


On Sep 12, 2008, at 9:21 AM, Jason Pruim wrote:



On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote:


Jason Pruim wrote:



nothing obvious to me.. so debug more!

?PHP

  function notify_email($Record, $salesRepID) {
echo in notify_email . PHP_EOL;
  require(defaults.php);
echo already loaded and required defaults loaded . PHP_EOL;
  require(func.sendemail.php);
echo require func.sendemail.php loaded . PHP_EOL;
  require(dbmysqliconnect.php);
echo already loaded and required dbmysqliconnect loaded . PHP_EOL;

will tell you where it's breaking I'd assume..


Okay, when I had that in the notify_email.php file it looked like it  
all loaded just fine... the echo's were displayed.


When I put that in my process.php file I got this output:
already loaded and required defaults loaded Just before send_email  
functionjust after send_email funtion

require func.sendemail.php loaded
already loaded and required dbmysqliconnect loaded
execute error Duplicate entry '0' for key 1

So I think Jochem might be right... Problem with mysqli?


Okay scratch that... I was attempting to update the auto_increment  
field so when I changed that, it got rid of the error but didn't fix  
the problem :)







--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]





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




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]





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



Re: [PHP] Re: Problem with function

2008-09-12 Thread Nathan Rixham

Jason Pruim wrote:


On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote:


Jason Pruim wrote:



nothing obvious to me.. so debug more!

?PHP

   function notify_email($Record, $salesRepID) {
echo in notify_email . PHP_EOL;
   require(defaults.php);
echo already loaded and required defaults loaded . PHP_EOL;
   require(func.sendemail.php);
echo require func.sendemail.php loaded . PHP_EOL;
   require(dbmysqliconnect.php);
echo already loaded and required dbmysqliconnect loaded . PHP_EOL;

will tell you where it's breaking I'd assume..


Okay, when I had that in the notify_email.php file it looked like it all 
loaded just fine... the echo's were displayed.


When I put that in my process.php file I got this output:
already loaded and required defaults loaded Just before send_email 
functionjust after send_email funtion

require func.sendemail.php loaded
already loaded and required dbmysqliconnect loaded
execute error Duplicate entry '0' for key 1

So I think Jochem might be right... Problem with mysqli?


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]






actually on closer inspection the problem looks here..

following requires 16 params:
mysqli_stmt_prepare($stmt, UPDATE purl.schreur SET
FName = ?,
LName = ?,
email = ?,
phone = ?,
record = ?,
subscribed = ?,
date = ?,
IPAddress = ?,
Business = ?,
Address1 = ?,
City = ?,
State = ?,
Zip = ?,
Coffee = ?,
Meeting = ?,
time = ?)
or die(prepare error  . mysqli_error($link));


17 params bound AND rdoTime + areaPlans are in wrong order or are just 
wrong..



mysqli_stmt_bind_param($stmt, '',
   $_POST['txtFName'],
   $_POST['txtLName'],
   $_POST['txtEmail'],
   $_POST['txtPhone'],
   $_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( bind error  . mysqli_error($link));

may help; probable causing the duplciate error problem; (doesn't explain 
first error though)


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



Re: [PHP] Re: Problem with function

2008-09-12 Thread Nathan Rixham

Nathan Rixham wrote:

Jason Pruim wrote:


On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote:


Jason Pruim wrote:



nothing obvious to me.. so debug more!

[snip snip snip]

have to say this:

error_reporting( E_ALL ); at the top would help; + display_errors on in 
php.ini and problem is probably due to duplciate variable/constant 
definition in default.php or dbmysqliconnect.php


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



Re: [PHP] Re: Problem with function

2008-09-12 Thread Jason Pruim


On Sep 12, 2008, at 9:34 AM, Nathan Rixham wrote:


Nathan Rixham wrote:

Jason Pruim wrote:


On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote:


Jason Pruim wrote:



nothing obvious to me.. so debug more!

[snip snip snip]

have to say this:

error_reporting( E_ALL ); at the top would help; + display_errors on  
in php.ini and problem is probably due to duplciate variable/ 
constant definition in default.php or dbmysqliconnect.php


I could agree more... which is why I have this:
ini_set('error_reporting', E_ALL);
But the log isn't showing anything...

My error log for the site has this:

[Fri Sep 12 09:40:54 2008] [debug] mod_rewrite.c(1643): [client  
192.168.0.253] mod_rewrite's internal redirect status: 0/10.


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]





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



Re: [PHP] Re: Problem with function

2008-09-12 Thread Jochem Maas

Jason Pruim schreef:


On Sep 12, 2008, at 9:34 AM, Nathan Rixham wrote:


Nathan Rixham wrote:

Jason Pruim wrote:


On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote:


Jason Pruim wrote:



nothing obvious to me.. so debug more!

[snip snip snip]

have to say this:

error_reporting( E_ALL ); at the top would help; + display_errors on 
in php.ini and problem is probably due to duplciate variable/constant 
definition in default.php or dbmysqliconnect.php


I could agree more... which is why I have this:
ini_set('error_reporting', E_ALL);
But the log isn't showing anything...


php.ini is what he said.


My error log for the site has this:

[Fri Sep 12 09:40:54 2008] [debug] mod_rewrite.c(1643): [client 
192.168.0.253] mod_rewrite's internal redirect status: 0/10.


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]








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



Re: [PHP] Re: Problem with function

2008-09-12 Thread Jason Pruim


On Sep 12, 2008, at 9:46 AM, Jochem Maas wrote:


Jason Pruim schreef:

On Sep 12, 2008, at 9:34 AM, Nathan Rixham wrote:

Nathan Rixham wrote:

Jason Pruim wrote:


On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote:


Jason Pruim wrote:



nothing obvious to me.. so debug more!

[snip snip snip]

have to say this:

error_reporting( E_ALL ); at the top would help; + display_errors  
on in php.ini and problem is probably due to duplciate variable/ 
constant definition in default.php or dbmysqliconnect.php

I could agree more... which is why I have this:
   ini_set('error_reporting', E_ALL);
But the log isn't showing anything...


php.ini is what he said.


isn't it the same difference?

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]





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



Re: [PHP] Re: Problem with function

2008-09-12 Thread Nathan Rixham

Jochem Maas wrote:

Jason Pruim schreef:


On Sep 12, 2008, at 9:34 AM, Nathan Rixham wrote:


Nathan Rixham wrote:

Jason Pruim wrote:


On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote:


Jason Pruim wrote:



nothing obvious to me.. so debug more!

[snip snip snip]

have to say this:

error_reporting( E_ALL ); at the top would help; + display_errors on 
in php.ini and problem is probably due to duplciate variable/constant 
definition in default.php or dbmysqliconnect.php


I could agree more... which is why I have this:
ini_set('error_reporting', E_ALL);
But the log isn't showing anything...


php.ini is what he said.


My error log for the site has this:

[Fri Sep 12 09:40:54 2008] [debug] mod_rewrite.c(1643): [client 
192.168.0.253] mod_rewrite's internal redirect status: 0/10.


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]







display_errors in php.ini is what you want; makes life easier while 
developing; and good to have E_STRICT and E_ALL set for err reporting; 
then you can catch every tiny potential future bug as well :)


ps did you read the one about your bind variables being in the wrong 
order and too many?


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