php-general Digest 22 Dec 2008 21:56:33 -0000 Issue 5860

Topics (messages 284952 through 284979):

Re: Replacing special characters with their HTML equivalents
        284952 by: Per Jessen

Re: Variable as an index
        284953 by: MikeP

First record not diplaying
        284954 by: Gary Maddock-Greene
        284955 by: Ashley Sheridan
        284956 by: Gary Maddock-Greene
        284957 by: Sándor Tamás (HostWare Kft.)
        284958 by: Richard Heyes
        284960 by: Wolf
        284961 by: Dan Shirah
        284962 by: Gary Maddock-Greene
        284963 by: Gary Maddock-Greene
        284964 by: Ashley Sheridan
        284965 by: Dan Shirah
        284966 by: Gary Maddock-Greene
        284967 by: Sándor Tamás (HostWare Kft.)
        284968 by: Gary Maddock-Greene
        284969 by: Gary Maddock-Greene

Re: eof bof in php
        284959 by: tedd
        284970 by: Anthony Gentile
        284971 by: Ashley Sheridan
        284972 by: Anthony Gentile
        284973 by: Ashley Sheridan

get_browser() too slow
        284974 by: Martin Zvarík
        284975 by: Martin Zvarík
        284977 by: Nathan Nobbe

Regular expressions (regex) question for parsing
        284976 by: Rene Fournier
        284978 by: Daniel Brown
        284979 by: Jim Lucas

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
James Colannino wrote:

> Hey everyone.  I have a question.  I have a web scraper that grabs
> information from web pages that often contain characters such as
> vowels with umlots (I know I spelled that wrong.)
> 
> The data is editable, so the characters show up unmodified in an
> editable text box.  However, when I try to import the data into a
> MySQL database, the first occurrence of such a character, along with
> the rest of the string, is truncated from the result. 

Your mysql table will have a characterset attribute - if what you're
inserting doesn't match, it will complain.  If converting with
htmlentities() works for your purpose, that's one solution, otherwise
I'd make the mysql table use UTF8 and then look into iconv to convert
all scraped pages to UTF8.


/Per Jessen, Zürich


--- End Message ---
--- Begin Message ---
Nevermind, Got it.
""MikeP"" <[email protected]> wrote in message 
news:[email protected]...
> Hello,
> I am trying to output the value of the following:($x is an int incremented 
> by a for statement.
>    echo "<tr>
>    <td width='110' bgcolor='$row_color' nowrap>
>   '$users[$x][U]'</td>
>    </tr>";
>
> I have tried putting the quotes all over and all I get is:
> 'Array[U]'.
>
> What am I doing wrong.
> Thanks
> Mike
> 



--- End Message ---
--- Begin Message --- Hi, I seem to have a bug in my code but can't see why. My first record does not display when I run a search. Can anyone spot what I have done wrong? Thanks

if (0 == $totalRows_rsSearch) {
echo "<h3>Sorry no products were found</h3>";
} else {
echo "<h3>Please click on a product for further information.</h3>";
while ($row_rsSearch = mysql_fetch_assoc($rsSearch)){
echo "<div class=\"productitem\"><img src=\"products".
$row_rsSearch['product_image']."\">

- Gary Maddock-Greene
--- End Message ---
--- Begin Message ---
On Mon, 2008-12-22 at 14:02 +0000, Gary Maddock-Greene wrote:
> Hi, I seem to have a bug in my code but can't see why. My first record does 
> not display when I run a search. Can anyone spot what I have done wrong? 
> Thanks
> 
> if (0 == $totalRows_rsSearch) {
> echo "<h3>Sorry no products were found</h3>";
> } else {
> echo "<h3>Please click on a product for further information.</h3>";
> while ($row_rsSearch = mysql_fetch_assoc($rsSearch)){
> echo "<div class=\"productitem\"><img src=\"products".
> $row_rsSearch['product_image']."\">
> 
> - Gary Maddock-Greene 
> 
> 
You seem to be missing quite a lot of code from your example, namely the
ending quotation mark, ending semicolon, the ending brace to the while
loop, the closing </div> tag inside the loop...

Also (and I know the speed junkies will want to shoot me now!) you could
shorten the echo inside the while loop to:

echo "<div class=\"productitem\"><img src=
\"products{$row_rsSearch['product_image']}\">";




Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message --- Ash ... this is the full code block ... I am really new to php so I appreciate your tip

<?php
// Good to go

if (0 == $totalRows_rsSearch) {
echo "<h3>Sorry no products were found</h3>";
} else {
echo "<h3>Please click on a product for further information.</h3>";
while ($row_rsSearch = mysql_fetch_assoc($rsSearch)){
echo "<div class=\"productitem\"><img src=\"products".
$row_rsSearch['product_image']."\">
      <div class=\"text\">
        <h3>". $row_rsSearch['product_name']."</h3>
          <p class=\"style1\">". $row_rsSearch['product_subtitle'] ."
</p>
          <a href=\"products". $row_rsSearch['product_url']."\">View
Product</a>
        <div class=\"clear\"></div>
        </div> <div class=\"clear\"></div>
     <center>
        </center>
      </div>";
}

}
?>

--
- Gary Maddock-Greene
"Ashley Sheridan" <[email protected]> wrote in message news:[email protected]...
On Mon, 2008-12-22 at 14:02 +0000, Gary Maddock-Greene wrote:
Hi, I seem to have a bug in my code but can't see why. My first record does
not display when I run a search. Can anyone spot what I have done wrong?
Thanks

if (0 == $totalRows_rsSearch) {
echo "<h3>Sorry no products were found</h3>";
} else {
echo "<h3>Please click on a product for further information.</h3>";
while ($row_rsSearch = mysql_fetch_assoc($rsSearch)){
echo "<div class=\"productitem\"><img src=\"products".
$row_rsSearch['product_image']."\">

- Gary Maddock-Greene


You seem to be missing quite a lot of code from your example, namely the
ending quotation mark, ending semicolon, the ending brace to the while
loop, the closing </div> tag inside the loop...

Also (and I know the speed junkies will want to shoot me now!) you could
shorten the echo inside the while loop to:

echo "<div class=\"productitem\"><img src=
\"products{$row_rsSearch['product_image']}\">";




Ash
www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
How do you know the record count for the query?

SanTa

----- Original Message ----- From: "Gary Maddock-Greene" <[email protected]>
To: <[email protected]>
Sent: Monday, December 22, 2008 3:02 PM
Subject: [PHP] First record not diplaying


Hi, I seem to have a bug in my code but can't see why. My first record does not display when I run a search. Can anyone spot what I have done wrong? Thanks

if (0 == $totalRows_rsSearch) {
echo "<h3>Sorry no products were found</h3>";
} else {
echo "<h3>Please click on a product for further information.</h3>";
while ($row_rsSearch = mysql_fetch_assoc($rsSearch)){
echo "<div class=\"productitem\"><img src=\"products".
$row_rsSearch['product_image']."\">

- Gary Maddock-Greene

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



--- End Message ---
--- Begin Message ---
> Also (and I know the speed junkies will want to shoot me now!) you could
> shorten the echo inside the while loop to:

You could shorten it even further by omitting it... :-)

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated December 20th)

--- End Message ---
--- Begin Message ---
---- Gary Maddock-Greene <[email protected]> wrote: 
> Hi, I seem to have a bug in my code but can't see why. My first record does 
> not display when I run a search. Can anyone spot what I have done wrong? 
> Thanks
> 
> if (0 == $totalRows_rsSearch) {
> echo "<h3>Sorry no products were found</h3>";
> } else {
> echo "<h3>Please click on a product for further information.</h3>";
> while ($row_rsSearch = mysql_fetch_assoc($rsSearch)){
> echo "<div class=\"productitem\"><img src=\"products".
> $row_rsSearch['product_image']."\">
> 
> - Gary Maddock-Greene 

Is this another one of your classes?  I see your email address links to a web 
page created for a class.

Without the rest of the code (the code above what you have placed) and the end 
of the echo line you have provided, all any of us can do is a guess.

However one thing to note, this list was not created to help you with your 
homework and with the previous postings you have written, it is pointedly 
answering different places you have stumbled in your work and haven't checked 
your book, the online resources, or a TA.

Wolf

--- End Message ---
--- Begin Message ---
>
> <?php
> // Good to go
>
> if (0 == $totalRows_rsSearch) {
> echo "<h3>Sorry no products were found</h3>";
> } else {
> echo "<h3>Please click on a product for further information.</h3>";
> while ($row_rsSearch = mysql_fetch_assoc($rsSearch)){
> echo "<div class=\"productitem\"><img src=\"products".
> $row_rsSearch['product_image']."\">
>      <div class=\"text\">
>        <h3>". $row_rsSearch['product_name']."</h3>
>          <p class=\"style1\">". $row_rsSearch['product_subtitle'] ."
> </p>
>          <a href=\"products". $row_rsSearch['product_url']."\">View
> Product</a>
>        <div class=\"clear\"></div>
>        </div> <div class=\"clear\"></div>
>     <center>
>        </center>
>      </div>";
> }
>
> }
> ?>


What is your value for $row_rsSearch  ??

--- End Message ---
--- Begin Message --- I know you are so right Richard .. beleive me ... I wish I was year down the line so I knew how to get the html out of the php

--
- Gary Maddock-Greene
""Richard Heyes"" <[email protected]> wrote in message news:[email protected]...
Also (and I know the speed junkies will want to shoot me now!) you could
shorten the echo inside the while loop to:

You could shorten it even further by omitting it... :-)

--
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated December 20th)


--- End Message ---
--- Begin Message ---
Very helpful thanks Wolf. fyi the web site you see was done by my son.

This is a live project that I was just asking for help on ... a pointer perhaps. Too much to ask I guess

--
- Gary Maddock-Greene
"Wolf" <[email protected]> wrote in message news:20081222141852.ovv8i.364383.r...@cdptpa-web15-z01...
---- Gary Maddock-Greene <[email protected]> wrote:
Hi, I seem to have a bug in my code but can't see why. My first record does
not display when I run a search. Can anyone spot what I have done wrong?
Thanks

if (0 == $totalRows_rsSearch) {
echo "<h3>Sorry no products were found</h3>";
} else {
echo "<h3>Please click on a product for further information.</h3>";
while ($row_rsSearch = mysql_fetch_assoc($rsSearch)){
echo "<div class=\"productitem\"><img src=\"products".
$row_rsSearch['product_image']."\">

- Gary Maddock-Greene

Is this another one of your classes? I see your email address links to a web page created for a class.

Without the rest of the code (the code above what you have placed) and the end of the echo line you have provided, all any of us can do is a guess.

However one thing to note, this list was not created to help you with your homework and with the previous postings you have written, it is pointedly answering different places you have stumbled in your work and haven't checked your book, the online resources, or a TA.

Wolf


--- End Message ---
--- Begin Message ---
On Mon, 2008-12-22 at 14:14 +0000, Gary Maddock-Greene wrote:

> Ash ... this is the full code block ... I am really new to php so I 
> appreciate your tip
> 
> <?php
> // Good to go
> 
> if (0 == $totalRows_rsSearch) {
> echo "<h3>Sorry no products were found</h3>";
> } else {
> echo "<h3>Please click on a product for further information.</h3>";
> while ($row_rsSearch = mysql_fetch_assoc($rsSearch)){
> echo "<div class=\"productitem\"><img src=\"products".
> $row_rsSearch['product_image']."\">
>        <div class=\"text\">
>          <h3>". $row_rsSearch['product_name']."</h3>
>            <p class=\"style1\">". $row_rsSearch['product_subtitle'] ."
> </p>
>            <a href=\"products". $row_rsSearch['product_url']."\">View
> Product</a>
>          <div class=\"clear\"></div>
>          </div> <div class=\"clear\"></div>
>       <center>
>          </center>
>        </div>";
> }
> 
> }
> ?>
> 
> -- 
> - Gary Maddock-Greene
> "Ashley Sheridan" <[email protected]> wrote in message 
> news:[email protected]...
> > On Mon, 2008-12-22 at 14:02 +0000, Gary Maddock-Greene wrote:
> >> Hi, I seem to have a bug in my code but can't see why. My first record 
> >> does
> >> not display when I run a search. Can anyone spot what I have done wrong?
> >> Thanks
> >>
> >> if (0 == $totalRows_rsSearch) {
> >> echo "<h3>Sorry no products were found</h3>";
> >> } else {
> >> echo "<h3>Please click on a product for further information.</h3>";
> >> while ($row_rsSearch = mysql_fetch_assoc($rsSearch)){
> >> echo "<div class=\"productitem\"><img src=\"products".
> >> $row_rsSearch['product_image']."\">
> >>
> >> - Gary Maddock-Greene
> >>
> >>
> > You seem to be missing quite a lot of code from your example, namely the
> > ending quotation mark, ending semicolon, the ending brace to the while
> > loop, the closing </div> tag inside the loop...
> >
> > Also (and I know the speed junkies will want to shoot me now!) you could
> > shorten the echo inside the while loop to:
> >
> > echo "<div class=\"productitem\"><img src=
> > \"products{$row_rsSearch['product_image']}\">";
> >
> >
> >
> >
> > Ash
> > www.ashleysheridan.co.uk
> > 
> 
> 

I've redone the code as best as I could without knowing where it fits in
with anything else just now. I've always found that keeping to a decent
indenting practise can help removing a lot of bugs like these.

<?php
// Good to go

if (0 == $totalRows_rsSearch)
{
        echo "<h3>Sorry no products were found</h3>";
}
else
{
        echo "<h3>Please click on a product for further information.</h3>";
        while ($row_rsSearch = mysql_fetch_assoc($rsSearch))
        {
                print <<<EOP
                <div class="productitem">
                        <img src="products{$row_rsSearch['product_image']}">
                <div class=\"text\">
                        <h3>{$row_rsSearch['product_name']}</h3>
                        <p 
class="style1">{$row_rsSearch['product_subtitle']}</p>
                        <a href="products{$row_rsSearch['product_url']}">View 
Product</a>
                        <div class="clear"/>
                </div>
                <div class="clear"/>
EOP;
        }
}
?>

Note, you're best off copying the code from the email that comes
straight to you from me, rather than the mailing list one, as the
mailing list will put line breaks in at bad points!


Ash
www.ashleysheridan.co.uk

--- End Message ---
--- Begin Message ---
>
>   Hi, I seem to have a bug in my code but can't see why. My first record
>>> does
>>> not display when I run a search. Can anyone spot what I have done wrong?
>>> Thanks
>>>
>>> if (0 == $totalRows_rsSearch) {
>>> echo "<h3>Sorry no products were found</h3>";
>>> } else {
>>> echo "<h3>Please click on a product for further information.</h3>";
>>> while ($row_rsSearch = mysql_fetch_assoc($rsSearch)){
>>> echo "<div class=\"productitem\"><img src=\"products".
>>> $row_rsSearch['product_image']."\">
>>>
>>> - Gary Maddock-Greene
>>>
>>
>> Is this another one of your classes?  I see your email address links to a
>> web page created for a class.
>>
>> Without the rest of the code (the code above what you have placed) and the
>> end of the echo line you have provided, all any of us can do is a guess.
>>
>> However one thing to note, this list was not created to help you with your
>> homework and with the previous postings you have written, it is pointedly
>> answering different places you have stumbled in your work and haven't
>> checked your book, the online resources, or a TA.
>>
>> Wolf
>
>
Like Wolf said...we need more code :)

My "guess" would be that you probably have the default value of your row
count set to start at 1...but the results of an array start at 0...therefore
your first row is being cutoff?

--- End Message ---
--- Begin Message ---
Thanks Dan,

So my error is here?
$colname_rsSearch = "-1";
if (isset($_GET['product_name'])) {
 $colname_rsSearch = $_GET['product_name'];
}
mysql_select_db($database_sondia_lighting, $sondia_lighting);
$query_rsSearch = sprintf("SELECT * FROM products WHERE product_name LIKE %s", GetSQLValueString("%" . $colname_rsSearch . "%", "text")); $rsSearch = mysql_query($query_rsSearch, $sondia_lighting) or die(mysql_error());
$row_rsSearch = mysql_fetch_assoc($rsSearch);
$totalRows_rsSearch = mysql_num_rows($rsSearch);

--
- Gary Maddock-Greene
""Dan Shirah"" <[email protected]> wrote in message news:[email protected]...
>
  Hi, I seem to have a bug in my code but can't see why. My first record
does
not display when I run a search. Can anyone spot what I have done wrong?
Thanks

if (0 == $totalRows_rsSearch) {
echo "<h3>Sorry no products were found</h3>";
} else {
echo "<h3>Please click on a product for further information.</h3>";
while ($row_rsSearch = mysql_fetch_assoc($rsSearch)){
echo "<div class=\"productitem\"><img src=\"products".
$row_rsSearch['product_image']."\">

- Gary Maddock-Greene


Is this another one of your classes? I see your email address links to a
web page created for a class.

Without the rest of the code (the code above what you have placed) and the
end of the echo line you have provided, all any of us can do is a guess.

However one thing to note, this list was not created to help you with your homework and with the previous postings you have written, it is pointedly
answering different places you have stumbled in your work and haven't
checked your book, the online resources, or a TA.

Wolf


Like Wolf said...we need more code :)

My "guess" would be that you probably have the default value of your row
count set to start at 1...but the results of an array start at 0...therefore
your first row is being cutoff?



--- End Message ---
--- Begin Message ---
Yes, the error is here.

You get the record count with a mysql_fetch_assoc(), which reads the first record, and then step onto the next one. So the first record's datas will disappear at the next mysql_fetch_assoc() line (which can be found in your while loop).

You should NOT fetch the first record, unless you fetch it in a variable to process datas at a later time.

SanTa


----- Original Message ----- From: "Gary Maddock-Greene" <[email protected]>
To: <[email protected]>
Sent: Monday, December 22, 2008 3:49 PM
Subject: Re: [PHP] First record not diplaying


Thanks Dan,

So my error is here?
$colname_rsSearch = "-1";
if (isset($_GET['product_name'])) {
 $colname_rsSearch = $_GET['product_name'];
}
mysql_select_db($database_sondia_lighting, $sondia_lighting);
$query_rsSearch = sprintf("SELECT * FROM products WHERE product_name LIKE %s", GetSQLValueString("%" . $colname_rsSearch . "%", "text")); $rsSearch = mysql_query($query_rsSearch, $sondia_lighting) or die(mysql_error());
$row_rsSearch = mysql_fetch_assoc($rsSearch);
$totalRows_rsSearch = mysql_num_rows($rsSearch);

--
- Gary Maddock-Greene
""Dan Shirah"" <[email protected]> wrote in message news:[email protected]...
>
  Hi, I seem to have a bug in my code but can't see why. My first record
does
not display when I run a search. Can anyone spot what I have done wrong?
Thanks

if (0 == $totalRows_rsSearch) {
echo "<h3>Sorry no products were found</h3>";
} else {
echo "<h3>Please click on a product for further information.</h3>";
while ($row_rsSearch = mysql_fetch_assoc($rsSearch)){
echo "<div class=\"productitem\"><img src=\"products".
$row_rsSearch['product_image']."\">

- Gary Maddock-Greene


Is this another one of your classes? I see your email address links to a
web page created for a class.

Without the rest of the code (the code above what you have placed) and the end of the echo line you have provided, all any of us can do is a guess.

However one thing to note, this list was not created to help you with your homework and with the previous postings you have written, it is pointedly
answering different places you have stumbled in your work and haven't
checked your book, the online resources, or a TA.

Wolf


Like Wolf said...we need more code :)

My "guess" would be that you probably have the default value of your row
count set to start at 1...but the results of an array start at 0...therefore
your first row is being cutoff?



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



--- End Message ---
--- Begin Message ---
very helpful thank you :)

--
- Gary Maddock-Greene
""Sándor Tamás (HostWare Kft . )"" <[email protected]> wrote in message news:dbb55d182b624f26be7f5125e592d...@stgepe...
Yes, the error is here.

You get the record count with a mysql_fetch_assoc(), which reads the first record, and then step onto the next one. So the first record's datas will disappear at the next mysql_fetch_assoc() line (which can be found in your while loop).

You should NOT fetch the first record, unless you fetch it in a variable to process datas at a later time.

SanTa


----- Original Message ----- From: "Gary Maddock-Greene" <[email protected]>
To: <[email protected]>
Sent: Monday, December 22, 2008 3:49 PM
Subject: Re: [PHP] First record not diplaying


Thanks Dan,

So my error is here?
$colname_rsSearch = "-1";
if (isset($_GET['product_name'])) {
 $colname_rsSearch = $_GET['product_name'];
}
mysql_select_db($database_sondia_lighting, $sondia_lighting);
$query_rsSearch = sprintf("SELECT * FROM products WHERE product_name LIKE %s", GetSQLValueString("%" . $colname_rsSearch . "%", "text")); $rsSearch = mysql_query($query_rsSearch, $sondia_lighting) or die(mysql_error());
$row_rsSearch = mysql_fetch_assoc($rsSearch);
$totalRows_rsSearch = mysql_num_rows($rsSearch);

--
- Gary Maddock-Greene
""Dan Shirah"" <[email protected]> wrote in message news:[email protected]...
>
Hi, I seem to have a bug in my code but can't see why. My first record
does
not display when I run a search. Can anyone spot what I have done wrong?
Thanks

if (0 == $totalRows_rsSearch) {
echo "<h3>Sorry no products were found</h3>";
} else {
echo "<h3>Please click on a product for further information.</h3>";
while ($row_rsSearch = mysql_fetch_assoc($rsSearch)){
echo "<div class=\"productitem\"><img src=\"products".
$row_rsSearch['product_image']."\">

- Gary Maddock-Greene


Is this another one of your classes? I see your email address links to a
web page created for a class.

Without the rest of the code (the code above what you have placed) and the end of the echo line you have provided, all any of us can do is a guess.

However one thing to note, this list was not created to help you with your homework and with the previous postings you have written, it is pointedly
answering different places you have stumbled in your work and haven't
checked your book, the online resources, or a TA.

Wolf


Like Wolf said...we need more code :)

My "guess" would be that you probably have the default value of your row
count set to start at 1...but the results of an array start at 0...therefore
your first row is being cutoff?



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




--- End Message ---
--- Begin Message --- so the correct way to do this is remove the $row_rsSearch = mysql_fetch_assoc($rsSearch); from my recordset query code. Thank you SanTa

--
- Gary Maddock-Greene
""Sándor Tamás (HostWare Kft . )"" <[email protected]> wrote in message news:dbb55d182b624f26be7f5125e592d...@stgepe...
Yes, the error is here.

You get the record count with a mysql_fetch_assoc(), which reads the first record, and then step onto the next one. So the first record's datas will disappear at the next mysql_fetch_assoc() line (which can be found in your while loop).

You should NOT fetch the first record, unless you fetch it in a variable to process datas at a later time.

SanTa


----- Original Message ----- From: "Gary Maddock-Greene" <[email protected]>
To: <[email protected]>
Sent: Monday, December 22, 2008 3:49 PM
Subject: Re: [PHP] First record not diplaying


Thanks Dan,

So my error is here?
$colname_rsSearch = "-1";
if (isset($_GET['product_name'])) {
 $colname_rsSearch = $_GET['product_name'];
}
mysql_select_db($database_sondia_lighting, $sondia_lighting);
$query_rsSearch = sprintf("SELECT * FROM products WHERE product_name LIKE %s", GetSQLValueString("%" . $colname_rsSearch . "%", "text")); $rsSearch = mysql_query($query_rsSearch, $sondia_lighting) or die(mysql_error());
$row_rsSearch = mysql_fetch_assoc($rsSearch);
$totalRows_rsSearch = mysql_num_rows($rsSearch);

--
- Gary Maddock-Greene
""Dan Shirah"" <[email protected]> wrote in message news:[email protected]...
>
Hi, I seem to have a bug in my code but can't see why. My first record
does
not display when I run a search. Can anyone spot what I have done wrong?
Thanks

if (0 == $totalRows_rsSearch) {
echo "<h3>Sorry no products were found</h3>";
} else {
echo "<h3>Please click on a product for further information.</h3>";
while ($row_rsSearch = mysql_fetch_assoc($rsSearch)){
echo "<div class=\"productitem\"><img src=\"products".
$row_rsSearch['product_image']."\">

- Gary Maddock-Greene


Is this another one of your classes? I see your email address links to a
web page created for a class.

Without the rest of the code (the code above what you have placed) and the end of the echo line you have provided, all any of us can do is a guess.

However one thing to note, this list was not created to help you with your homework and with the previous postings you have written, it is pointedly
answering different places you have stumbled in your work and haven't
checked your book, the online resources, or a TA.

Wolf


Like Wolf said...we need more code :)

My "guess" would be that you probably have the default value of your row
count set to start at 1...but the results of an array start at 0...therefore
your first row is being cutoff?



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




--- End Message ---
--- Begin Message ---
At 1:21 PM -0500 12/21/08, Anthony Gentile wrote:
-snip exampe-


is probably going to give you the result you want. However you should know
it is bad practice to mix PHP and HTML as horridly as I just showed you. AKA
you don't want your PHP writing your HTML.

Anthony Gentile

Anthony:

Granted, the example you gave was a bit mixed, but it's perfectly Okay to have php write html. In fact, if you think about it that's the only way php can express itself to the user. A simple echo($var) is writing html to a browser.

Good practice should to write code (i.e., php, mysql, css, html, js) that is semantic and compliant with standards. Mixing them well is almost an art form that observes best practices in all.

Cheers,

tedd

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

--- End Message ---
--- Begin Message ---
I would argue it is better practice as:

<h1><?php echo 'Hello World'; ?></h1>

than

<?php
echo "<h1>Hello World</h1>";
?>
Anthony Gentile


On Mon, Dec 22, 2008 at 9:18 AM, tedd <[email protected]> wrote:

> At 1:21 PM -0500 12/21/08, Anthony Gentile wrote:
>
>> -snip exampe-
>>
>>
>> is probably going to give you the result you want. However you should know
>> it is bad practice to mix PHP and HTML as horridly as I just showed you.
>> AKA
>> you don't want your PHP writing your HTML.
>>
>> Anthony Gentile
>>
>
> Anthony:
>
> Granted, the example you gave was a bit mixed, but it's perfectly Okay to
> have php write html. In fact, if you think about it that's the only way php
> can express itself to the user. A simple echo($var) is writing html to a
> browser.
>
> Good practice should to write code (i.e., php, mysql, css, html, js) that
> is semantic and compliant with standards. Mixing them well is almost an art
> form that observes best practices in all.
>
> 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
>
>

--- End Message ---
--- Begin Message ---
On Mon, 2008-12-22 at 14:21 -0500, Anthony Gentile wrote:
> I would argue it is better practice as:
> 
> <h1><?php echo 'Hello World'; ?></h1>
> 
> than
> 
> <?php
> echo "<h1>Hello World</h1>";
> ?>
> Anthony Gentile
> 
> 
> On Mon, Dec 22, 2008 at 9:18 AM, tedd <[email protected]> wrote:
> 
> > At 1:21 PM -0500 12/21/08, Anthony Gentile wrote:
> >
> >> -snip exampe-
> >>
> >>
> >> is probably going to give you the result you want. However you should know
> >> it is bad practice to mix PHP and HTML as horridly as I just showed you.
> >> AKA
> >> you don't want your PHP writing your HTML.
> >>
> >> Anthony Gentile
> >>
> >
> > Anthony:
> >
> > Granted, the example you gave was a bit mixed, but it's perfectly Okay to
> > have php write html. In fact, if you think about it that's the only way php
> > can express itself to the user. A simple echo($var) is writing html to a
> > browser.
> >
> > Good practice should to write code (i.e., php, mysql, css, html, js) that
> > is semantic and compliant with standards. Mixing them well is almost an art
> > form that observes best practices in all.
> >
> > 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
> >
> >
Why?! As you've seen, it can get awfully messy very quickly...


Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
Well you said it...for my example it makes sense. For when it gets really
messy by all means concatenate with php. However, my argument is not so much
keeping html seperate from php as it is keeping the business logic separate
from the presentation....so if you have php writing html and its all dealing
with the presentation...I personally don't think its a problem. However when
you start writing html out with php in your business logic...to me that's a
no no.

Anthony Gentile



On Mon, Dec 22, 2008 at 2:47 PM, Ashley Sheridan
<[email protected]>wrote:

> On Mon, 2008-12-22 at 14:21 -0500, Anthony Gentile wrote:
> > I would argue it is better practice as:
> >
> > <h1><?php echo 'Hello World'; ?></h1>
> >
> > than
> >
> > <?php
> > echo "<h1>Hello World</h1>";
> > ?>
> > Anthony Gentile
> >
> >
> > On Mon, Dec 22, 2008 at 9:18 AM, tedd <[email protected]> wrote:
> >
> > > At 1:21 PM -0500 12/21/08, Anthony Gentile wrote:
> > >
> > >> -snip exampe-
> > >>
> > >>
> > >> is probably going to give you the result you want. However you should
> know
> > >> it is bad practice to mix PHP and HTML as horridly as I just showed
> you.
> > >> AKA
> > >> you don't want your PHP writing your HTML.
> > >>
> > >> Anthony Gentile
> > >>
> > >
> > > Anthony:
> > >
> > > Granted, the example you gave was a bit mixed, but it's perfectly Okay
> to
> > > have php write html. In fact, if you think about it that's the only way
> php
> > > can express itself to the user. A simple echo($var) is writing html to
> a
> > > browser.
> > >
> > > Good practice should to write code (i.e., php, mysql, css, html, js)
> that
> > > is semantic and compliant with standards. Mixing them well is almost an
> art
> > > form that observes best practices in all.
> > >
> > > 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
> > >
> > >
> Why?! As you've seen, it can get awfully messy very quickly...
>
>
> Ash
> www.ashleysheridan.co.uk
>
>

--- End Message ---
--- Begin Message ---
On Mon, 2008-12-22 at 15:04 -0500, Anthony Gentile wrote:
> Well you said it...for my example it makes sense. For when it gets really
> messy by all means concatenate with php. However, my argument is not so much
> keeping html seperate from php as it is keeping the business logic separate
> from the presentation....so if you have php writing html and its all dealing
> with the presentation...I personally don't think its a problem. However when
> you start writing html out with php in your business logic...to me that's a
> no no.
> 
> Anthony Gentile
> 
> 
> 
> On Mon, Dec 22, 2008 at 2:47 PM, Ashley Sheridan
> <[email protected]>wrote:
> 
> > On Mon, 2008-12-22 at 14:21 -0500, Anthony Gentile wrote:
> > > I would argue it is better practice as:
> > >
> > > <h1><?php echo 'Hello World'; ?></h1>
> > >
> > > than
> > >
> > > <?php
> > > echo "<h1>Hello World</h1>";
> > > ?>
> > > Anthony Gentile
> > >
> > >
> > > On Mon, Dec 22, 2008 at 9:18 AM, tedd <[email protected]> wrote:
> > >
> > > > At 1:21 PM -0500 12/21/08, Anthony Gentile wrote:
> > > >
> > > >> -snip exampe-
> > > >>
> > > >>
> > > >> is probably going to give you the result you want. However you should
> > know
> > > >> it is bad practice to mix PHP and HTML as horridly as I just showed
> > you.
> > > >> AKA
> > > >> you don't want your PHP writing your HTML.
> > > >>
> > > >> Anthony Gentile
> > > >>
> > > >
> > > > Anthony:
> > > >
> > > > Granted, the example you gave was a bit mixed, but it's perfectly Okay
> > to
> > > > have php write html. In fact, if you think about it that's the only way
> > php
> > > > can express itself to the user. A simple echo($var) is writing html to
> > a
> > > > browser.
> > > >
> > > > Good practice should to write code (i.e., php, mysql, css, html, js)
> > that
> > > > is semantic and compliant with standards. Mixing them well is almost an
> > art
> > > > form that observes best practices in all.
> > > >
> > > > 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
> > > >
> > > >
> > Why?! As you've seen, it can get awfully messy very quickly...
> >
> >
> > Ash
> > www.ashleysheridan.co.uk
> >
> >
I largely tend towards using heredoc syntax wherever possible, as it
lets you separate the PHP and HTML in the way you want, yet still allows
you to have variable output inside the HTML. I hate repetitious breaking
out of HTML code just to output a variable or two.


Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
Hello,
anyone has a good function for getting a user's browser, OS and crawler detection ?

I have looked at google etc, but I ran only into long list of ineffective ereg()s functions or not checking if it's crawler...

Is it possible to make an array list and just check using strpos() each one?
The basic browsers for Win, Mac, and Linux - others would be unknown.
And then only to check for OS.

I tryed get_browser() but that thing is way too slow for my needs: 0.09 sec.

Thanks in advance,
Martin

--- End Message ---
--- Begin Message ---
Martin Zvarík napsal(a):
Hello,
anyone has a good function for getting a user's browser, OS and crawler detection ?

I have looked at google etc, but I ran only into long list of ineffective ereg()s functions or not checking if it's crawler...

Is it possible to make an array list and just check using strpos() each one?
The basic browsers for Win, Mac, and Linux - others would be unknown.
And then only to check for OS.

I tryed get_browser() but that thing is way too slow for my needs: 0.09 sec.

Thanks in advance,
Martin

Hmm... This one is decent:
http://techpatterns.com/downloads/scripts/browser_detection_php_ar.txt

--- End Message ---
--- Begin Message ---
2008/12/22 Martin Zvarík <[email protected]>

> Martin Zvarík napsal(a):
>
>> Hello,
>> anyone has a good function for getting a user's browser, OS and crawler
>> detection ?
>>
>> I have looked at google etc, but I ran only into long list of ineffective
>> ereg()s functions or not checking if it's crawler...
>>
>> Is it possible to make an array list and just check using strpos() each
>> one?
>> The basic browsers for Win, Mac, and Linux - others would be unknown.
>> And then only to check for OS.
>>
>> I tryed get_browser() but that thing is way too slow for my needs: 0.09
>> sec.
>>
>> Thanks in advance,
>> Martin
>>
>
> Hmm... This one is decent:
> http://techpatterns.com/downloads/scripts/browser_detection_php_ar.txt


theres something akin to this in code igniter, though more than likely, its
not as feature rich.

-nathan

--- End Message ---
--- Begin Message --- Hi, I'm looking for some ideas on the best way to parse blocks of text that is formatted such as:

$sometext %\r\n                                         -- good data            
$otherstring %\r\n                                              -- good data
$andyetmoretext %\r\n                                   -- good data
$finaltext                                                              -- bad 
data (missing ending)

Each line should start with a $dollar sign, then some arbitrary text, ends with a percent sign, followed by carriage-return and line-feed. Sometimes though, the final line is not complete. In that case, I want to save those lines too.

....so that I end up with an array like:

$result = array (       "matches" =>
                array ( 0 => "$sometext %\r\n",
                                1 => "$otherstring %\r\n",
                                2 => "$andyetmoretext %\r\n"
                                ),
        "non_matches" =>
                array ( 3 => "$finaltext"
                                )
                        );

The key thing here is that the line numbers are preserved and the non- matched lines are saved...

Any ideas, what's the best way to go about this? Preg_matc, preg_split or something incorporating explode?

....Rene

--- End Message ---
--- Begin Message ---
On Mon, Dec 22, 2008 at 15:56, Rene Fournier <[email protected]> wrote:
>
> Each line should start with a $dollar sign, then some arbitrary text, ends
> with a percent sign, followed by carriage-return and line-feed. Sometimes
> though, the final line is not complete. In that case, I want to save those
> lines too.

    Just a quick note on that, Rene....

> $result = array (       "matches" =>
>                array ( 0 => "$sometext %\r\n",

    If you want to have the dollar sign included, use single quotes.
Double-quoted things translate the data enclosed within them, so
"$sometext" would translate that into the value of the variable (or
null with E_NOTICE if it's uninstantiated/undefined).  Conversely,
'$sometext' would be the literal $sometext.

-- 
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

--- End Message ---
--- Begin Message ---
Rene Fournier wrote:
> Hi, I'm looking for some ideas on the best way to parse blocks of text
> that is formatted such as:
> 
> $sometext %\r\n                        -- good data       
> $otherstring %\r\n                        -- good data
> $andyetmoretext %\r\n                    -- good data
> $finaltext                                 -- bad data (missing ending)
> 
> Each line should start with a $dollar sign, then some arbitrary text,
> ends with a percent sign, followed by carriage-return and line-feed.
> Sometimes though, the final line is not complete. In that case, I want
> to save those lines too.
> 
> ....so that I end up with an array like:
> 
> $result = array (    "matches" =>
>         array (    0 => "$sometext %\r\n",
>                 1 => "$otherstring %\r\n",
>                 2 => "$andyetmoretext %\r\n"
>                 ),
>     "non_matches" =>
>         array (    3 => "$finaltext"
>                 )
>             );
> 
> The key thing here is that the line numbers are preserved and the
> non-matched lines are saved...
> 
> Any ideas, what's the best way to go about this? Preg_matc, preg_split
> or something incorporating explode?
> 
> ....Rene
> 

Something along the line of this?

<pre><?php

$block_of_text = '$sometext %\r\n
$otherstring %\r\n
$andyetmoretext %\r\n
$finaltext';

$lines = explode("\n", $block_of_text);

$results = array();

foreach ( $lines AS $i => $line ) {
        if ( preg_match('|^\$.* %\\\r\\\n$|', $line ) ) {
                $results['matches'][$i] = $line;
        } else {
                $results['non_matches'][$i] = $line;
        }
}

print_r($results);

?>


-- 
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

--- End Message ---

Reply via email to