...

View Full Version : No freakin' output...



grumpy
08-07-2008, 08:28 AM
Hi,

In my php script that calculates numbers from letters the issue is that no output occurs even though there are plenty of echo calls. The sql query might be incorrect (the UNION bit) or some other stuff. Let's first tackle the sql part:

The query:


$query = "SELECT `SubscriberID`, `EmailAddress`, `FirstName`,
`LastName` FROM `InfResp_subscribers` WHERE `SubscriberID` = $id AND
`EmailAddress` = '$email' UNION ALL SELECT `email_attached`, `reason`,
`income`, `interest` FROM `InfResp_customfields`WHERE `email_attached`
= '$email' AND `fieldID` = $id";

The tables:

http://scoliosissolution.com/dbscreen1.png

http://scoliosissolution.com/dbscreen2.png

I can also provide the complete code for inspection :)

Thank you so much for the help.

Bo

oesxyl
08-07-2008, 08:34 AM
try this:

$query = "SELECT `SubscriberID`, `EmailAddress`, `FirstName`,
`LastName` FROM `InfResp_subscribers` WHERE `SubscriberID` = $id AND
`EmailAddress` = '".$email."' UNION ALL SELECT `email_attached`, `reason`,
`income`, `interest` FROM `InfResp_customfields`WHERE `email_attached`
= '".$email."' AND `fieldID` = $id";

and post code, :)

regards

grumpy
08-07-2008, 09:14 AM
The problem persists even with that query fix.

I've set set_time_limit(0); for testing and the script just keeps on running and running until wamp starts to freeze - unlimited loop?

Here's the code (http://scoliosissolution.com/code.txt).

Thanks.

oesxyl
08-07-2008, 09:32 AM
The problem persists even with that query fix.

I've set set_time_limit(0); for testing and the script just keeps on running and running until wamp starts to freeze - unlimited loop?

Here's the code:

http://scoliosissolution.com/code.txt

Thanks.

this kind?


$life_path = ($day_out + $month_out + $year_out);
while ($life_path > 9)
{
$life_path_out = array_sum(preg_split('//', $life_path, -1, PREG_SPLIT_NO_EMPTY));
}
echo $life_path_out;

output is $life_path_out and in condition is $life_path. $life_path is not change or I miss something.

same thing $name_num and $name_num_1, $full_name_num and $full_name_num_1 and few others.

regards

grumpy
08-07-2008, 10:20 AM
Thank you! At least it's giving some output now (even though it's wrong) and I have no errors or warnings. Fixing the calculations now...

grumpy
08-07-2008, 10:37 AM
Did all your recommendations and it outputs:

1email@yahoo.comTestTestemail@yahoo.com12091985

So it actually reads ok from the db. Now,the problem that I see from the output is that it outputs the email twice even though it's echoed only once. Is UNION ALL the right thing to include here or would some other call be better?

oesxyl
08-07-2008, 10:55 AM
Did all your recommendations and it outputs:

1email@yahoo.comTestTestemail@yahoo.com12091985

So it actually reads ok from the db. Now,the problem that I see from the output is that it outputs the email twice even though it's echoed only once. Is UNION ALL the right thing to include here or would some other call be better?
I never used union, :)

InfResp_subscribers is one-to-many with InfResp_customfields ?
I mean, this query work?


select a.SubscriberID, a.EmailAddress, a.FirstName, a.LastName,
b.email_attached, b.reason, b.income, b.interest
from InfResp_subscribers as a, InfResp_customfields as b
where a.SubscriberID = $id and a.EmailAddress = $email and
b.email_attached = $email and b.fieldID = $id


regards

grumpy
08-07-2008, 11:15 AM
THAT is a very neat trick. Just like doing it directly through mysql not php with the dots but assigning a value. Who needs JOINs and UNIONs :)

It worked - the email now only outputs once. The calculations are still wrong and I am correcting these. Will let you know...

oesxyl
08-07-2008, 11:26 AM
THAT is a very neat trick. Just like doing it directly through mysql not php with the dots but assigning a value. Who needs JOINs and UNIONs :)

It worked - the email now only outputs once. The calculations are still wrong and I am correcting these. Will let you know...
you still need to quote $email, but probably you already know, :)



$query = "select a.SubscriberID, a.EmailAddress, a.FirstName, a.LastName,
b.email_attached, b.reason, b.income, b.interest
from InfResp_subscribers as a, InfResp_customfields as b
where a.SubscriberID = $id and a.EmailAddress = '".$email."' and
b.email_attached = '".$email."' and b.fieldID = $id


regards

grumpy
08-07-2008, 11:35 AM
Yes I did quote it :)

Now, am I passing values to the NumTable function OK? For the three calculations that use this function it outputs just zeroes. I guess I am doing it wrong:


$name_out = ($fname_out . $lname_out);
$name_out_array = preg_split('//', $name_out, -1, PREG_SPLIT_NO_EMPTY);
$name_out_array = $letter;
for ($i=0; $i <= sizeof($letter); $i++)
{
NumTable ($letter, $i);
}
$name_num = array_sum(array ($letter));

Should I use foreach instead and forget about the $i?

How would I do that?

oesxyl
08-07-2008, 05:40 PM
I guess that something is wrong with error reporting, try this:



ini_set('display_errors', 1);
error_reporting(E_ALL);
# include the db logon file
require 'qetu1369/datbz.php';
#require 'qetu1369/text.php';

# set the limit execution time to unlimited
set_time_limit(0);
// error_reporting (E_ALL & ~E_NOTICE); # show all errors except notices



Yes I did quote it :)

Now, am I passing values to the NumTable function OK? For the three calculations that use this function it outputs just zeroes. I guess I am doing it wrong:


$name_out = ($fname_out . $lname_out);
$name_out_array = preg_split('//', $name_out, -1, PREG_SPLIT_NO_EMPTY);
$name_out_array = $letter;
for ($i=0; $i <= sizeof($letter); $i++)
{
NumTable ($letter, $i);
}
$name_num = array_sum(array ($letter));

Should I use foreach instead and forget about the $i?

How would I do that?

1. add a 'return $letter;' to the end of NumTable function
2. change the part you posted to this:



$name_out = ($fname_out . $lname_out);
$name_out_array = preg_split('//', $name_out, -1, PREG_SPLIT_NO_EMPTY);
//$name_out_array = $letter;
$letter = $name_out_array;
//for ($i=0; $i <= sizeof($letter); $i++)
foreach($letter as $i => $v){
NumTable ($letter, $i);
}
$name_num = array_sum(array ($letter));


BUT I have no idea if it do what must do because I don't understand what must do. Could you give me a clue? :)

regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum