473,799 Members | 3,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Having trouble with left join

I'm getting NULLs where there shouldn't be. Any help is appreciated.

Here are the tables:

precinct

Field Type Null Key Default Extra
id smallint(6) PRI NULL auto_increment
precinct_number int(11) 0
precinct_name varchar(20) MUL
countydist smallint(6) 0
congdist smallint(6) 0
legdist smallint(6) 0

"precinct_n ame" is the name of the precinct, not the PCO. That's in
the next table.

pcolist
Field Type Null Key Default Extra
id smallint(6) PRI NULL auto_increment
precinct int(11) 0
pctname varchar(15)
area varchar(4)
legdist smallint(6) 0
countydist smallint(6) 0
congdist smallint(6) 0
name varchar(50)
email varchar(50) MUL
private tinyint(1) 0
type varchar(5)

I know there are some duplicates here, which is what I'm trying to
solve by this join statement:

SELECT king_precinct.p recinct_number AS precinct_number ,
king_precinct.p recinct_name AS precinct_name, king_precinct.l egdist AS
legdist, king_precinct.c ountydist AS countydist,
king_precinct.c ongdist AS congdist, pcolist.name AS name, pcolist.type
AS type
FROM king_precinct LEFT JOIN pcolist
ON king_precinct.p recinct_number = pcolist.precinc t
ORDER BY precinct_name

The problem is that it's not bringing up the name of the PCO in the
final result. Can anyone see what I'm doing wrong within the SQL
statement? If not, I can post the code I'm using.

Chad Lupkes
Seattle

Mar 27 '07 #1
9 1745
chadlupkes wrote:
I'm getting NULLs where there shouldn't be.
To determine that, we'd need to see some of the data.
king_precinct
You've not given us a schema for this table.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
Mar 27 '07 #2
chadlupkes wrote:
I'm getting NULLs where there shouldn't be. Any help is appreciated.

Here are the tables:

precinct

Field Type Null Key Default Extra
id smallint(6) PRI NULL auto_increment
precinct_number int(11) 0
precinct_name varchar(20) MUL
countydist smallint(6) 0
congdist smallint(6) 0
legdist smallint(6) 0

"precinct_n ame" is the name of the precinct, not the PCO. That's in
the next table.

pcolist
Field Type Null Key Default Extra
id smallint(6) PRI NULL auto_increment
precinct int(11) 0
pctname varchar(15)
area varchar(4)
legdist smallint(6) 0
countydist smallint(6) 0
congdist smallint(6) 0
name varchar(50)
email varchar(50) MUL
private tinyint(1) 0
type varchar(5)

I know there are some duplicates here, which is what I'm trying to
solve by this join statement:

SELECT king_precinct.p recinct_number AS precinct_number ,
king_precinct.p recinct_name AS precinct_name, king_precinct.l egdist AS
legdist, king_precinct.c ountydist AS countydist,
king_precinct.c ongdist AS congdist, pcolist.name AS name, pcolist.type
AS type
FROM king_precinct LEFT JOIN pcolist
ON king_precinct.p recinct_number = pcolist.precinc t
ORDER BY precinct_name

The problem is that it's not bringing up the name of the PCO in the
final result. Can anyone see what I'm doing wrong within the SQL
statement? If not, I can post the code I'm using.

Chad Lupkes
Seattle
Chad,

I don't see a PHP question here. In fact, I don't see any PHP here at all.

Maybe you should be asking in a newsgroup related to your database?

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Mar 28 '07 #3
Sorry! king_precinct is the same as the precinct table. Forgot to
adjust it in both locations.

And since this is a PHP forum, which Jerry reminded me of, here is the
code I'm trying to get to work:

echo('<html>
<head>
<title>Precinct s in King County</title>
</head>
<body>
<table border="1">
<tr>
<th>Precinct Number</th>
<th>Precinct Name</th>
<th>County Council District</th>
<th>Congression al District</th>
<th>Legislati ve District</th>
<th>PCO Name</th>
<th>PCO Type</th>
</tr>
');
$link_id = db_connect('wa4 6dems_data');
$result = mysql_query("SE LECT king_precinct.p recinct_number AS
precinct_number , king_precinct.p recinct_name AS precinct_name,
king_precinct.l egdist AS legdist, king_precinct.c ountydist AS
countydist, king_precinct.c ongdist AS congdist, pcolist.name AS name,
pcolist.type AS type
FROM king_precinct LEFT JOIN pcolist
ON king_precinct.p recinct_number = pcolist.precinc t
ORDER BY precinct_name", $link_id);
while($pct_data = mysql_fetch_arr ay($result)) {
$precinct_numbe r = $pct_data["precinct_numbe r"];
$precinct_name = $pct_data["precinct_n ame"];
$precinct_cc = $pct_data["countydist "];
$precinct_cd = $pct_data["congdist"];
$precinct_ld = $pct_data["legdist"];
$precinct_pco_n ame = $query_data["name"];
$precinct_pco_e mail = $query_data["email"];
$precinct_pco_p rivate = $query_data["private"];
$precinct_pco_t ype = $query_data["type"];
echo('
<tr>
<td>'.$precinct _number.'</td>
<td><a href="precinctm ap.php?pct='.$p recinct_number. '">'.
$precinct_name. '</a></td>
<td>'.$precinct _cc.'</td>
<td>'.$precinct _cd.'</td>
<td>'.$precinct _ld.'</td>
<td>'.$precinct _pco_name.'</td>
<td>'.$precinct _pco_type.'</td>
</tr>');
}
echo('</table>');

On Mar 27, 8:24 am, Toby A Inkster <usenet200...@t obyinkster.co.u k>
wrote:
chadlupkes wrote:
I'm getting NULLs where there shouldn't be.

To determine that, we'd need to see some of the data.
king_precinct

You've not given us a schema for this table.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!

Mar 28 '07 #4
Hi Jerry,

Please see my other post for the PHP code. I've been busy today and
couldn't get to my system until now.

I think it's something to do with my PHP code, because when I run the
SQL query within mysql, it works exactly how I want it to. I think
I'm doing something wrong in the code, but I just can't see it.

Thanks!

Chad

On Mar 27, 7:01 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
chadlupkes wrote:
I'm getting NULLs where there shouldn't be. Any help is appreciated.
Here are the tables:
precinct
Field Type Null Key Default Extra
id smallint(6) PRI NULL auto_increment
precinct_number int(11) 0
precinct_name varchar(20) MUL
countydist smallint(6) 0
congdist smallint(6) 0
legdist smallint(6) 0
"precinct_n ame" is the name of the precinct, not the PCO. That's in
the next table.
pcolist
Field Type Null Key Default Extra
id smallint(6) PRI NULL auto_increment
precinct int(11) 0
pctname varchar(15)
area varchar(4)
legdist smallint(6) 0
countydist smallint(6) 0
congdist smallint(6) 0
name varchar(50)
email varchar(50) MUL
private tinyint(1) 0
type varchar(5)
I know there are some duplicates here, which is what I'm trying to
solve by this join statement:
SELECT king_precinct.p recinct_number AS precinct_number ,
king_precinct.p recinct_name AS precinct_name, king_precinct.l egdist AS
legdist, king_precinct.c ountydist AS countydist,
king_precinct.c ongdist AS congdist, pcolist.name AS name, pcolist.type
AS type
FROM king_precinct LEFT JOIN pcolist
ON king_precinct.p recinct_number = pcolist.precinc t
ORDER BY precinct_name
The problem is that it's not bringing up the name of the PCO in the
final result. Can anyone see what I'm doing wrong within the SQL
statement? If not, I can post the code I'm using.
Chad Lupkes
Seattle

Chad,

I don't see a PHP question here. In fact, I don't see any PHP here at all.

Maybe you should be asking in a newsgroup related to your database?

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attgl obal.net
=============== ===

Mar 28 '07 #5
chadlupkes wrote:
On Mar 27, 8:24 am, Toby A Inkster <usenet200...@t obyinkster.co.u k>
wrote:
>chadlupkes wrote:
>>I'm getting NULLs where there shouldn't be.
To determine that, we'd need to see some of the data.
>>king_precin ct
You've not given us a schema for this table.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!


Sorry! king_precinct is the same as the precinct table. Forgot to
adjust it in both locations.

And since this is a PHP forum, which Jerry reminded me of, here is the
code I'm trying to get to work:

echo('<html>
<head>
<title>Precinct s in King County</title>
</head>
<body>
<table border="1">
<tr>
<th>Precinct Number</th>
<th>Precinct Name</th>
<th>County Council District</th>
<th>Congression al District</th>
<th>Legislati ve District</th>
<th>PCO Name</th>
<th>PCO Type</th>
</tr>
');
$link_id = db_connect('wa4 6dems_data');
$result = mysql_query("SE LECT king_precinct.p recinct_number AS
precinct_number , king_precinct.p recinct_name AS precinct_name,
king_precinct.l egdist AS legdist, king_precinct.c ountydist AS
countydist, king_precinct.c ongdist AS congdist, pcolist.name AS name,
pcolist.type AS type
FROM king_precinct LEFT JOIN pcolist
ON king_precinct.p recinct_number = pcolist.precinc t
ORDER BY precinct_name", $link_id);
while($pct_data = mysql_fetch_arr ay($result)) {
$precinct_numbe r = $pct_data["precinct_numbe r"];
$precinct_name = $pct_data["precinct_n ame"];
$precinct_cc = $pct_data["countydist "];
$precinct_cd = $pct_data["congdist"];
$precinct_ld = $pct_data["legdist"];
$precinct_pco_n ame = $query_data["name"];
$precinct_pco_e mail = $query_data["email"];
$precinct_pco_p rivate = $query_data["private"];
$precinct_pco_t ype = $query_data["type"];
echo('
<tr>
<td>'.$precinct _number.'</td>
<td><a href="precinctm ap.php?pct='.$p recinct_number. '">'.
$precinct_name. '</a></td>
<td>'.$precinct _cc.'</td>
<td>'.$precinct _cd.'</td>
<td>'.$precinct _ld.'</td>
<td>'.$precinct _pco_name.'</td>
<td>'.$precinct _pco_type.'</td>
</tr>');
}
echo('</table>');
(Top posting fixed)

PHP isn't going to affect whether your SQL code returns null values or
not. If a particular row contains a null, you'll get a null back from
your sql. And since you're doing a left join, if there is no matching
row in pcolist you will get nulls for all values there.

And you're still asking about the SQL, not PHP. You need to be asking
in a SQL newsgroup - you'll get much better help on your SQL question.

And please don't top post.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Mar 28 '07 #6
On Mar 28, 5:38 am, Jerry Stuckle <jstuck...@attg lobal.netwrote:
chadlupkes wrote:
On Mar 27, 8:24 am, Toby A Inkster <usenet200...@t obyinkster.co.u k>
wrote:
chadlupkes wrote:
I'm getting NULLs where there shouldn't be.
To determine that, we'd need to see some of the data.
>king_precinc t
You've not given us a schema for this table.
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux
* = I'm getting there!
Here are the tables:

king_precinct

Field Type Null Key Default Extra
id smallint(6) PRI NULL auto_increment
precinct_number int(11) 0
precinct_name varchar(20) MUL
countydist smallint(6) 0
congdist smallint(6) 0
legdist smallint(6) 0

"precinct_n ame" is the name of the precinct, not the PCO. That's in
the next table.

pcolist
Field Type Null Key Default Extra
id smallint(6) PRI NULL auto_increment
precinct int(11) 0
pctname varchar(15)
area varchar(4)
legdist smallint(6) 0
countydist smallint(6) 0
congdist smallint(6) 0
name varchar(50)
email varchar(50) MUL
private tinyint(1) 0
type varchar(5)
>
And since this is a PHP forum, which Jerry reminded me of, here is the
code I'm trying to get to work:
>
echo('<html>
<head>
<title>Precinct s in King County</title>
</head>
<body>
<table border="1">
<tr>
<th>Precinct Number</th>
<th>Precinct Name</th>
<th>County Council District</th>
<th>Congression al District</th>
<th>Legislati ve District</th>
<th>PCO Name</th>
<th>PCO Type</th>
</tr>
');
$link_id = db_connect('wa4 6dems_data');
$result = mysql_query("SE LECT king_precinct.p recinct_number AS precinct_number , king_precinct.p recinct_name AS precinct_name, king_precinct.l egdist AS legdist, king_precinct.c ountydist AS countydist, king_precinct.c ongdist AS congdist, pcolist.name AS name, pcolist.type AS type
FROM king_precinct LEFT JOIN pcolist
ON king_precinct.p recinct_number = pcolist.precinc t
ORDER BY precinct_name", $link_id);
while($pct_data = mysql_fetch_arr ay($result)) {
$precinct_numbe r = $pct_data["precinct_numbe r"];
$precinct_name = $pct_data["precinct_n ame"];
$precinct_cc = $pct_data["countydist "];
$precinct_cd = $pct_data["congdist"];
$precinct_ld = $pct_data["legdist"];
$precinct_pco_n ame = $query_data["name"];
$precinct_pco_e mail = $query_data["email"];
$precinct_pco_p rivate = $query_data["private"];
$precinct_pco_t ype = $query_data["type"];
echo('
<tr>
<td>'.$precinct _number.'</td>
<td><a href="precinctm ap.php?pct='.$p recinct_number. '">'.
$precinct_name. '</a></td>
<td>'.$precinct _cc.'</td>
<td>'.$precinct _cd.'</td>
<td>'.$precinct _ld.'</td>
<td>'.$precinct _pco_name.'</td>
<td>'.$precinct _pco_type.'</td>
</tr>');
}
echo('</table>');
>

(Top posting fixed)

PHP isn't going to affect whether your SQL code returns null values or
not. If a particular row contains a null, you'll get a null back from
your sql. And since you're doing a left join, if there is no matching
row in pcolist you will get nulls for all values there.

And you're still asking about the SQL, not PHP. You need to be asking
in a SQL newsgroup - you'll get much better help on your SQL question.

And please don't top post.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attgl obal.net
=============== ===
I think it's something to do with my PHP code, because when I run the
SQL query within mysql, it works exactly how I want it to. I think
I'm doing something wrong in the code, but I just can't see it.

You can see the results that are coming out of the query here:

http://46dems.com/kcdems/precinctinfo_html.php

I'll copy the mysql group to see if anyone there has ideas that might
work.

Mar 29 '07 #7
chadlupkes wrote:
On Mar 28, 5:38 am, Jerry Stuckle <jstuck...@attg lobal.netwrote:
>chadlupkes wrote:
>>On Mar 27, 8:24 am, Toby A Inkster <usenet200...@t obyinkster.co.u k>
wrote:
chadlupkes wrote:
I'm getting NULLs where there shouldn't be.
To determine that, we'd need to see some of the data.
king_precin ct
You've not given us a schema for this table.
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux
* = I'm getting there!
Here are the tables:

king_precinct

Field Type Null Key Default Extra
id smallint(6) PRI NULL auto_increment
precinct_number int(11) 0
precinct_name varchar(20) MUL
countydist smallint(6) 0
congdist smallint(6) 0
legdist smallint(6) 0

"precinct_n ame" is the name of the precinct, not the PCO. That's in
the next table.

pcolist
Field Type Null Key Default Extra
id smallint(6) PRI NULL auto_increment
precinct int(11) 0
pctname varchar(15)
area varchar(4)
legdist smallint(6) 0
countydist smallint(6) 0
congdist smallint(6) 0
name varchar(50)
email varchar(50) MUL
private tinyint(1) 0
type varchar(5)
> >
And since this is a PHP forum, which Jerry reminded me of, here is the
code I'm trying to get to work:

echo('<html>
<head>
<title>Precinct s in King County</title>
</head>
<body>
<table border="1">
<tr>
<th>Precinct Number</th>
<th>Precinct Name</th>
<th>County Council District</th>
<th>Congression al District</th>
<th>Legislati ve District</th>
<th>PCO Name</th>
<th>PCO Type</th>
</tr>
');
$link_id = db_connect('wa4 6dems_data');
$result = mysql_query("SE LECT king_precinct.p recinct_number AS precinct_number , king_precinct.p recinct_name AS precinct_name, king_precinct.l egdist AS legdist, king_precinct.c ountydist AS countydist, king_precinct.c ongdist AS congdist, pcolist.name AS name, pcolist.type AS type
FROM king_precinct LEFT JOIN pcolist
ON king_precinct.p recinct_number = pcolist.precinc t
ORDER BY precinct_name", $link_id);
while($pct_data = mysql_fetch_arr ay($result)) {
$precinct_numbe r = $pct_data["precinct_numbe r"];
$precinct_name = $pct_data["precinct_n ame"];
$precinct_cc = $pct_data["countydist "];
$precinct_cd = $pct_data["congdist"];
$precinct_ld = $pct_data["legdist"];
$precinct_pco_n ame = $query_data["name"];
$precinct_pco_e mail = $query_data["email"];
$precinct_pco_p rivate = $query_data["private"];
$precinct_pco_t ype = $query_data["type"];
echo('
<tr>
<td>'.$precinct _number.'</td>
<td><a href="precinctm ap.php?pct='.$p recinct_number. '">'.
$precinct_name. '</a></td>
<td>'.$precinct _cc.'</td>
<td>'.$precinct _cd.'</td>
<td>'.$precinct _ld.'</td>
<td>'.$precinct _pco_name.'</td>
<td>'.$precinct _pco_type.'</td>
</tr>');
}
echo('</table>');

(Top posting fixed)

PHP isn't going to affect whether your SQL code returns null values or
not. If a particular row contains a null, you'll get a null back from
your sql. And since you're doing a left join, if there is no matching
row in pcolist you will get nulls for all values there.

And you're still asking about the SQL, not PHP. You need to be asking
in a SQL newsgroup - you'll get much better help on your SQL question.

And please don't top post.

--
============== ====
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attg lobal.net
============== ====

I think it's something to do with my PHP code, because when I run the
SQL query within mysql, it works exactly how I want it to. I think
I'm doing something wrong in the code, but I just can't see it.

You can see the results that are coming out of the query here:

http://46dems.com/kcdems/precinctinfo_html.php

I'll copy the mysql group to see if anyone there has ideas that might
work.
Chad,

I just took another look at this (actually in the comp.databases. mysql
group) and your output. Your problem is right here:

$precinct_pco_n ame = $query_data["name"];
$precinct_pco_e mail = $query_data["email"];
$precinct_pco_p rivate = $query_data["private"];
$precinct_pco_t ype = $query_data["type"];

The problem is your result is in $pct_data from:

while($pct_data = mysql_fetch_arr ay($result))

A suggestion - any time you have problems like this, check your PHP
error log (usually the webserver's error log) or add the following to
the beginning of your script:

error_reporting (E_ALL);
ini_set("displa y_errors", "1");

This will display all errors, warnings, notices, etc. You should have
gotten a notice on the above statements (missing index in the array - if
it is even an array);

So I was wrong and it was a PHP error - but something like when you have
both mysql and php involved it never hurts to post to both groups.

And actually seeing the output helped a lot.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Mar 29 '07 #8
chadlupkes wrote:
I think it's something to do with my PHP code, because when I run the
SQL query within mysql, it works exactly how I want it to.
Permissions?

Are you running the queries under the same set of permissions in both
cases?

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
Mar 29 '07 #9
On Mar 29, 8:13 am, Jerry Stuckle <jstuck...@attg lobal.netwrote:
chadlupkes wrote:
On Mar 28, 5:38 am, Jerry Stuckle <jstuck...@attg lobal.netwrote:
chadlupkes wrote:
On Mar 27, 8:24 am, Toby A Inkster <usenet200...@t obyinkster.co.u k>
wrote:
chadlupkes wrote:
I'm getting NULLs where there shouldn't be.
To determine that, we'd need to see some of the data.
king_precinc t
You've not given us a schema for this table.
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux
* = I'm getting there!
Here are the tables:
king_precinct
Field Type Null Key Default Extra
id smallint(6) PRI NULL auto_increment
precinct_number int(11) 0
precinct_name varchar(20) MUL
countydist smallint(6) 0
congdist smallint(6) 0
legdist smallint(6) 0
"precinct_n ame" is the name of the precinct, not the PCO. That's in
the next table.
pcolist
Field Type Null Key Default Extra
id smallint(6) PRI NULL auto_increment
precinct int(11) 0
pctname varchar(15)
area varchar(4)
legdist smallint(6) 0
countydist smallint(6) 0
congdist smallint(6) 0
name varchar(50)
email varchar(50) MUL
private tinyint(1) 0
type varchar(5)
And since this is a PHP forum, which Jerry reminded me of, here is the
code I'm trying to get to work:
echo('<html>
<head>
<title>Precinct s in King County</title>
</head>
<body>
<table border="1">
<tr>
<th>Precinct Number</th>
<th>Precinct Name</th>
<th>County Council District</th>
<th>Congression al District</th>
<th>Legislati ve District</th>
<th>PCO Name</th>
<th>PCO Type</th>
</tr>
');
$link_id = db_connect('wa4 6dems_data');
$result = mysql_query("SE LECT king_precinct.p recinct_number AS precinct_number , king_precinct.p recinct_name AS precinct_name, king_precinct.l egdist AS legdist, king_precinct.c ountydist AS countydist, king_precinct.c ongdist AS congdist, pcolist.name AS name, pcolist.type AS type
FROM king_precinct LEFT JOIN pcolist
ON king_precinct.p recinct_number = pcolist.precinc t
ORDER BY precinct_name", $link_id);
while($pct_data = mysql_fetch_arr ay($result)) {
$precinct_numbe r = $pct_data["precinct_numbe r"];
$precinct_name = $pct_data["precinct_n ame"];
$precinct_cc = $pct_data["countydist "];
$precinct_cd = $pct_data["congdist"];
$precinct_ld = $pct_data["legdist"];
$precinct_pco_n ame = $query_data["name"];
$precinct_pco_e mail = $query_data["email"];
$precinct_pco_p rivate = $query_data["private"];
$precinct_pco_t ype = $query_data["type"];
echo('
<tr>
<td>'.$precinct _number.'</td>
<td><a href="precinctm ap.php?pct='.$p recinct_number. '">'.
$precinct_name. '</a></td>
<td>'.$precinct _cc.'</td>
<td>'.$precinct _cd.'</td>
<td>'.$precinct _ld.'</td>
<td>'.$precinct _pco_name.'</td>
<td>'.$precinct _pco_type.'</td>
</tr>');
}
echo('</table>');
(Top posting fixed)
PHP isn't going to affect whether your SQL code returns null values or
not. If a particular row contains a null, you'll get a null back from
your sql. And since you're doing a left join, if there is no matching
row in pcolist you will get nulls for all values there.
And you're still asking about the SQL, not PHP. You need to be asking
in a SQL newsgroup - you'll get much better help on your SQL question.
And please don't top post.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attgl obal.net
=============== ===
I think it's something to do with my PHP code, because when I run the
SQL query within mysql, it works exactly how I want it to. I think
I'm doing something wrong in the code, but I just can't see it.
You can see the results that are coming out of the query here:
http://46dems.com/kcdems/precinctinfo_html.php
I'll copy the mysql group to see if anyone there has ideas that might
work.

Chad,

I just took another look at this (actually in the comp.databases. mysql
group) and your output. Your problem is right here:

$precinct_pco_n ame = $query_data["name"];
$precinct_pco_e mail = $query_data["email"];
$precinct_pco_p rivate = $query_data["private"];
$precinct_pco_t ype = $query_data["type"];

The problem is your result is in $pct_data from:

while($pct_data = mysql_fetch_arr ay($result))

A suggestion - any time you have problems like this, check your PHP
error log (usually the webserver's error log) or add the following to
the beginning of your script:

error_reporting (E_ALL);
ini_set("displa y_errors", "1");

This will display all errors, warnings, notices, etc. You should have
gotten a notice on the above statements (missing index in the array - if
it is even an array);

So I was wrong and it was a PHP error - but something like when you have
both mysql and php involved it never hurts to post to both groups.

And actually seeing the output helped a lot.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attgl obal.net
=============== ===
Isn't it true that 90% of errors like this just need an extra pair of
eyes? Thanks, Jerry. I really appreciate your help.

http://46dems.com/kcdems/precinctinfo_html.php

Chad

Mar 30 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1765
by: Geremy | last post by:
Hi Consider two tables id1 code1 ----------- ----- 1 a 2 b 3 c id2 code2 value
4
4108
by: jbm05 | last post by:
Hi, I'm curious about the computational complexity of a query I have. The query contains multiple nested self left joins, starting with a simple select, then doing a self left join with the results, then doing a self left join with those results, etc. What puzzles me is that the time required for the query seems to grow exponentially as I add additional left joins, which I didn't expect. I expected the inner select to return about 25...
2
1371
by: bob | last post by:
Could someone help me get the following SQL statement working? SELECT standardgame.gamename, standardgame.rowteamname, standardgame.colteamname, standardgame.dollarvalue, standardgame.gameid, standardgame.cutoffdatetime, standardgame.gametype,
1
1251
by: Giordano | last post by:
I am trying to construct a report menu that will allow the user to select any combination of 3 variables from 3 combo boxes (Select Subject/SelectCategory/Date Range). There are 2 possible options for each combo ie <Allor a specific value . That means there are 8 possible outcomes from the user selection process. The SQL for the report is constructed 'on the fly' when the report is opened, using a series of "if" calculations in the...
6
1925
by: cberthu | last post by:
Hi all, I have a strange (at least for me) things happening. I am save the result of an outer join into a file and I read this file and put these values into a table. The first row written contains the code page... how comes did I do something wrong or is it a normal behavior? I have to say that I did not manage to insert the value directly from outer join....... I am not a DB2 Specialist.
5
2416
JustJim
by: JustJim | last post by:
I think I've just bumped into the limits of the Having Clause (Help file says 40 expressions, Mary says 99 and I know who I trust). The question is, what happens if you overload the select... into... having clause? Does the whole thing fail? Is the clause truncated somehow? It appears that the target table is being deleted, but then not re-created! Here's what I got so far. Please pardon the long lines, I don't type 'em, I just paste...
1
2690
by: ced69 | last post by:
having trouble getting marquee to work get object required errors tring t <title>This Month at the Chamberlain Civic Center</title> <link href="styles.css" rel="stylesheet" type="text/css" /> <script src="Dunbarlab9.js" type="text/javascript"></script> <script type="text/javascript">
1
1513
by: jeddiki | last post by:
Hi, I am having difficulty seeing why my divs will not swap places :confused: I want to swap the positions of the "Hot News" and the "Todays Bonuese" sections. Here is how they look now: http://www.expert-world.com/im/images/trash1.jpg
5
13387
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL http://mghospedagem.com/images/controlpanel.jpg instead of http://mghospedagem.comhttp://mghospedagem.com/images/controlpanel.jpg As u see, there's the website URL before the image URL.
0
9546
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10268
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10247
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10031
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9079
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7571
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5593
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4146
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.