Re: [PHP] can't output sql query with php code.

2006-02-06 Thread Jay Paulson
It always helps to have a different point of view to look at code sometimes.
Else you'll go bonkers looking for that stupid semi-colon! :)




On 2/6/06 2:18 AM, "Paul Goepfert" <[EMAIL PROTECTED]> wrote:

> Thanks everyone for your help.  I should have seen the semi-colon at
> the end of the while loop.  I must have looked at the code 20 times
> and I can't believe I missed it.
> 
> Paul
> On 2/6/06, Brady Mitchell <[EMAIL PROTECTED]> wrote:
>>> >> echo '\n';
>>> $month_query = mysql_query("SELECT m_id, months FROM Month");
>>> while ($r = mysql_fetch_array($month_query));
>> 
>> 
>> Remove the semi-colon at the end of the above line and it works like a charm.
>> 
>>> {
>>> $v = $r["m_id"];
>>> $out = $r["months"];
>>> echo "$out\n";
>>> }
>>> echo '\n';
>>> ?>
>> 
>> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

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



Re: [PHP] can't output sql query with php code.

2006-02-06 Thread Paul Goepfert
Thanks everyone for your help.  I should have seen the semi-colon at
the end of the while loop.  I must have looked at the code 20 times
and I can't believe I missed it.

Paul
On 2/6/06, Brady Mitchell <[EMAIL PROTECTED]> wrote:
> >  > echo '\n';
> > $month_query = mysql_query("SELECT m_id, months FROM Month");
> > while ($r = mysql_fetch_array($month_query));
>
>
> Remove the semi-colon at the end of the above line and it works like a charm.
>
> > {
> > $v = $r["m_id"];
> > $out = $r["months"];
> > echo "$out\n";
> > }
> > echo '\n';
> > ?>
>
>

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



RE: [PHP] can't output sql query with php code.

2006-02-06 Thread Brady Mitchell
>  echo '\n';
> $month_query = mysql_query("SELECT m_id, months FROM Month");
> while ($r = mysql_fetch_array($month_query));

 
Remove the semi-colon at the end of the above line and it works like a charm.
 
> {
> $v = $r["m_id"];
> $out = $r["months"];   
> echo "$out\n";
> }
> echo '\n';
> ?>

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



Re: [PHP] can't output sql query with php code.

2006-02-06 Thread Sumeet

Paul Goepfert wrote:

This is the full code for the code that doesn't work.

\n';
$month_query = mysql_query("SELECT m_id, months FROM Month");
while ($r = mysql_fetch_array($month_query));
{
$v = $r["m_id"];
$out = $r["months"];  
echo "$out\n";
}
echo '\n';
?>


dear sir,

overall, i can see no visible error. but u must debug the process.

1. please add print_r($r) within the while loop to see the contents.
2. check the num of rows returned by mysql_query.
3. check it mysql_query is not returning an error.


--
Sumeet Shroff
http://www.prateeksha.com
Web Design and Ecommerce Development, Mumbai India

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



Re: [PHP] can't output sql query with php code.

2006-02-05 Thread Paul Goepfert
This is the full code for the code that doesn't work.

\n';
$month_query = mysql_query("SELECT m_id, months FROM Month");
while ($r = mysql_fetch_array($month_query));
{
$v = $r["m_id"];
$out = $r["months"];
echo "$out\n";
}
echo '\n';
?>

On 2/6/06, Brady Mitchell <[EMAIL PROTECTED]> wrote:
> > Doesn't work
> > -
> >  > $month_query = mysql_query("SELECT m_id, months FROM Month");
> > while ($row = mysql_fetch_array($month_query))
> > {
> >  $val = $row["m_id"];
> >  $out = $row["months"];
> >  echo "$out";
> > }
> > ?>
>
> You're missing the  tags.
>
> > while ($r = mysql_fetch_array($Equip_query))
> > {
> >  $val = $r["equip"];
> >  echo "$val\n";
> > }
>
> On a seperate note, if all you are doing with the $val variable is using it 
> to echo, it's not needed.  Put brackets { } around the var to echo ie: 
> {$r["equip]} - makes it easier to read later when you come back to tweak your 
> code.
>
> Brady
>
>
>
>
>
>

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



RE: [PHP] can't output sql query with php code.

2006-02-05 Thread Brady Mitchell
> Doesn't work
> -
>  $month_query = mysql_query("SELECT m_id, months FROM Month");
> while ($row = mysql_fetch_array($month_query))
> {
>  $val = $row["m_id"];
>  $out = $row["months"];
>  echo "$out";
> }
> ?>

You're missing the  tags.

> while ($r = mysql_fetch_array($Equip_query))
> {
>  $val = $r["equip"];
>  echo "$val\n";
> }

On a seperate note, if all you are doing with the $val variable is using it to 
echo, it's not needed.  Put brackets { } around the var to echo ie: 
{$r["equip]} - makes it easier to read later when you come back to tweak your 
code.

Brady

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



Re: [PHP] can't output sql query with php code.

2006-02-05 Thread Chris

Hi Paul,

If "equip" contains a space it will probably break the dropdown.

Change it to:

echo "$val\n";

in case it has quotes, spaces, < or > in it.

Paul Goepfert wrote:

Hi all,

I have a mysql database setup to use with my php web page.  I have
been able to access the database and get values into my drop down
menus.  However when I tried to output the contents into two two
diferent variables the code does not work.  To be more specific I will
show you the code both the one that works and the one that doesn't

Doesn't work
-
$out";
}
?>

-
Code that works
-
';
$Equip_query = mysql_query("SELECT equip FROM Equipment ORDER BY
equip ASC");

while ($r = mysql_fetch_array($Equip_query))
{
 $val = $r["equip"];
 echo "$val\n";
}
echo "";
?>

Also I should tell you that the code that works comes after the code
that doesn't work in my web page.

Oh for the values that are outputted in the code that doesn't work are
val is numeric and out is a string.

I know my sql query works because I tested it in mysql.

Thanks for the help

Paul



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



[PHP] can't output sql query with php code.

2006-02-05 Thread Paul Goepfert
Hi all,

I have a mysql database setup to use with my php web page.  I have
been able to access the database and get values into my drop down
menus.  However when I tried to output the contents into two two
diferent variables the code does not work.  To be more specific I will
show you the code both the one that works and the one that doesn't

Doesn't work
-
$out";
}
?>

-
Code that works
-
';
$Equip_query = mysql_query("SELECT equip FROM Equipment ORDER BY
equip ASC");

while ($r = mysql_fetch_array($Equip_query))
{
 $val = $r["equip"];
 echo "$val\n";
}
echo "";
?>

Also I should tell you that the code that works comes after the code
that doesn't work in my web page.

Oh for the values that are outputted in the code that doesn't work are
val is numeric and out is a string.

I know my sql query works because I tested it in mysql.

Thanks for the help

Paul

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