Re: [PHP] Passing var from one page to itself

2008-12-21 Thread kspal

hello,
you can use session to store your variables between pages.



Aslan a écrit :

Hey there,

I have a problem where I have a simple -script that I am  wanting to 
pass back to itself three times

1) Symptoms -  2) Troubleshooting questions 3) Answer to problem

The page is passing the vars from the first page to the second, but 
the first pages vars are not passed to the third (but the second page is)


I am using includes for each sectional page and passing it back to 
itself


   if($submitted == )
   {
include 'inc/tshoot2-input.php';
   }
   if($submitted == symptoms)
   {
include 'inc/tshoot2-symptoms.php'; }
   if($submitted == submitted)
   {
include 'inc/answers.php';   }

The tool will ultimately be on www.adslgeek.com/troubleshooter/

I have it currently all on one page, but it isn't quite what I was after
..
Any help would be appreciated!

Cheers
ADSL Geek



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



Re: [PHP] Image Resizing

2008-12-21 Thread Kevin Waterson
This one time, at band camp, Stephen Alistoun stephenalist...@gmail.com wrote:

 
 I want all the images to resize to 100px width but the height adjusts
 automatically.


Two ways, GD or Imagick

http://www.phpro.org/examples/GD-Thumbnail-Based-On-Image-Type.html

http://www.phpro.org/tutorials/Imagick.html#4

Kevin

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



Re: [PHP] Image Resizing

2008-12-21 Thread Jason Paschal
i use imageMagick:

?php

$image_path = ../images/myimage.jpg;   //path to the image from my
script
$thumb_path = ../thumbnails/mymage.jpg;//path to where i want the
thumbnail to be created

$width = 100; //greatest allowed width for my thumbnails
$height = 100; //greatest allowed height for my thumbnails

//make the thumbnail
//imageMagick will automatically adjust for aspect ratio with this command
line
//however, if you want to force a thumbnail to the preset dimensions,
//put an exclamation point after $height

//http://www.imagemagick.org/Magick++/Geometry.html

$command_line = convert -geometry $width . x . $height $image_path
$thumb_path;

system($command_line, $return_var);

if ($return_var == 1) {

echo Thumbnail creation failed! :(;

} else {

echo Thumbnail created. :) a href='$thumb_path' target='_blank'View
Thumbnail FFS/a;

}

?

if you run into problems, and assuming imageMagick was successfully
installed:

- make sure you have write permission for where you want the thumbnail to be
created

- try replacing convert with the full path to the convert app.
e.g.
 $command_line = /usr/bin/convert -geometry etc;

- run the script from the command line.  ssh in to your script's directory
and try typing this:

 php thumbscript.php

   you'll see verbose messages to help you pinpoint the problem. depending
on your setup, you might have to put in the full path to php

- if you're still stuck, try putting in this line:

   ?php
   ini_set(display_errors,1);

information like this would have saved me hours of my life




On Sun, Dec 21, 2008 at 3:54 AM, Kevin Waterson ke...@phpro.org wrote:

 This one time, at band camp, Stephen Alistoun stephenalist...@gmail.com
 wrote:


  I want all the images to resize to 100px width but the height adjusts
  automatically.


 Two ways, GD or Imagick

 http://www.phpro.org/examples/GD-Thumbnail-Based-On-Image-Type.html

 http://www.phpro.org/tutorials/Imagick.html#4

 Kevin

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




-- 
Crunchmutt Studios
Latest News Headlines: http://www.rssvideonews.com
http://www.imagepoop.com
http://www.crunchmutt.com
http://www.deadjoe.com
http://www.dailymedication.com
http://www.extremesportclips.com
http://www.coolanimalclips.com
http://www.robotclips.com
http://www.newsfinger.com
http://www.postyourimage.com
http://www.nakedalarmclock.com


Re: [PHP] Passing var from one page to itself

2008-12-21 Thread Jason Paschal
also, you can store info in hidden form fields.  on the 2nd page, populate
the hidden fields with the data from the first page.  when that form is
submitted, the hidden field values will get submitted as well.

that's not ideal, tho.  if you have validation in place between the first
and second pages, that could be obviated if someone who knew some stuff
changed the hidden field values before it gets sent to the 3rd page.

you could do the session vars as the previous person suggested, but if you
have a lot of data to store, you might want to consider putting it into a
database using the session_id as the identifier.

On Sun, Dec 21, 2008 at 3:10 AM, kspal i...@kspal.com wrote:

 hello,
 you can use session to store your variables between pages.



 Aslan a écrit :

  Hey there,

 I have a problem where I have a simple -script that I am  wanting to pass
 back to itself three times
 1) Symptoms -  2) Troubleshooting questions 3) Answer to problem

 The page is passing the vars from the first page to the second, but the
 first pages vars are not passed to the third (but the second page is)

 I am using includes for each sectional page and passing it back to
 itself

   if($submitted == )
   {
include 'inc/tshoot2-input.php';
   }
   if($submitted == symptoms)
   {
include 'inc/tshoot2-symptoms.php'; }
   if($submitted == submitted)
   {
include 'inc/answers.php';   }

 The tool will ultimately be on www.adslgeek.com/troubleshooter/

 I have it currently all on one page, but it isn't quite what I was after
 ..
 Any help would be appreciated!

 Cheers
 ADSL Geek


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




-- 
Crunchmutt Studios
Latest News Headlines: http://www.rssvideonews.com
http://www.imagepoop.com
http://www.crunchmutt.com
http://www.deadjoe.com
http://www.dailymedication.com
http://www.extremesportclips.com
http://www.coolanimalclips.com
http://www.robotclips.com
http://www.newsfinger.com
http://www.postyourimage.com
http://www.nakedalarmclock.com


[PHP] Repeat Region Error

2008-12-21 Thread Gary Maddock-Greene

Hi  All,

I am getting the following error - Warning: mysql_fetch_assoc(): 3 is not a 
valid MySQL result resource in 


I think it has something to do with my Dreamweaver created code for a repeat 
region. The head code is:


?php
if (!function_exists(GetSQLValueString)) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = , 
$theNotDefinedValue = )

{
 $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

 $theValue = function_exists(mysql_real_escape_string) ? 
mysql_real_escape_string($theValue) : mysql_escape_string($theValue);


 switch ($theType) {
   case text:
 $theValue = ($theValue != ) ? ' . $theValue . ' : NULL;
 break;
   case long:
   case int:
 $theValue = ($theValue != ) ? intval($theValue) : NULL;
 break;
   case double:
 $theValue = ($theValue != ) ? ' . doubleval($theValue) . ' : 
NULL;

 break;
   case date:
 $theValue = ($theValue != ) ? ' . $theValue . ' : NULL;
 break;
   case defined:
 $theValue = ($theValue != ) ? $theDefinedValue : 
$theNotDefinedValue;

 break;
 }
 return $theValue;
}
}

$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);
?
?php
mysql_free_result($rsSearch);
?


... and the code in the page to generate my region is:

?php do { ?
 div class=productitemimg src=products?php echo 
$row_rsSearch['product_image']; ? /

   div class=text
 h3?php echo $row_rsSearch['product_name']; ?/h3
   p class=style1?php echo $row_rsSearch['product_subtitle']; 
?/p
   a href=products?php echo $row_rsSearch['product_url']; 
?View Product/a

 div class=clear/div
 /div div class=clear/div
  center
 /center
   /div
 ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?

If anyone can assist I would really appreciate it

- Gary 



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



[PHP] Re: Repeat Region Error

2008-12-21 Thread Gary Maddock-Greene

Sorry guys .. resolved it doh!

I was freeing the recordset in

?php
mysql_free_result($rsSearch);
?

-Gary

Gary Maddock-Greene g...@maddock-greene.co.uk wrote in message 
news:5a.42.33998.4b83e...@pb1.pair.com...

Hi  All,

I am getting the following error - Warning: mysql_fetch_assoc(): 3 is not 
a valid MySQL result resource in 


I think it has something to do with my Dreamweaver created code for a 
repeat region. The head code is:


?php
if (!function_exists(GetSQLValueString)) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = , 
$theNotDefinedValue = )

{
 $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

 $theValue = function_exists(mysql_real_escape_string) ? 
mysql_real_escape_string($theValue) : mysql_escape_string($theValue);


 switch ($theType) {
   case text:
 $theValue = ($theValue != ) ? ' . $theValue . ' : NULL;
 break;
   case long:
   case int:
 $theValue = ($theValue != ) ? intval($theValue) : NULL;
 break;
   case double:
 $theValue = ($theValue != ) ? ' . doubleval($theValue) . ' : 
NULL;

 break;
   case date:
 $theValue = ($theValue != ) ? ' . $theValue . ' : NULL;
 break;
   case defined:
 $theValue = ($theValue != ) ? $theDefinedValue : 
$theNotDefinedValue;

 break;
 }
 return $theValue;
}
}

$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);
?
?php
mysql_free_result($rsSearch);
?


... and the code in the page to generate my region is:

?php do { ?
 div class=productitemimg src=products?php echo 
$row_rsSearch['product_image']; ? /

   div class=text
 h3?php echo $row_rsSearch['product_name']; ?/h3
   p class=style1?php echo $row_rsSearch['product_subtitle']; 
?/p
   a href=products?php echo $row_rsSearch['product_url']; 
?View Product/a

 div class=clear/div
 /div div class=clear/div
  center
 /center
   /div
 ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?

If anyone can assist I would really appreciate it

- Gary 



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



Re: [PHP] Re: imap_rfc822_parse_adrlist problem

2008-12-21 Thread Ben Stuyts

Hi,

On 21 dec 2008, at 03:41, Manuel Lemos wrote:


on 12/20/2008 09:34 PM Ben Stuyts said the following:

Hi,

Since upgrading to php 5.2.8 I have a problem with
imap_rfc822_parse_adrlist. When I run the example given on the manual
page at http://nl3.php.net/imap_rfc822_parse_adrlist:
...
So the host part isn't filled in correctly. I have verified this on  
two
FreeBSD 7 machines. On an older FreeBSD 5 machine with php4 this  
works

fine. Before the update, I was running php 5.2.6 and there was no
problem either. Any ideas?


Sometime ago I decided to not use IMAP library functions to parse e- 
mail
addresses because it was not handling all sorts of addresses as it  
should.


Well, yeah, ok, I read about the problems imap_rfc822_parse_adrlist()  
has, but shouldn't it just work at least as advertized in the manual?  
Plus, this is breaking an existing application (Twiggi).



Nowadays I use an e-mail address parser class written in pure PHP that
comes with this MIME parser class:

http://www.phpclasses.org/mimeparser


Thanks, I'll have a look at that.

Ben


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



Re: [PHP] Image Resizing

2008-12-21 Thread tedd

At 12:38 PM -0800 12/20/08, Stephen Alistoun wrote:

Hi all,

What is the best way in PHP to Resize an Image to a specific width.

For Example I have images in the following sizes:

(1) 200px width and 350px height
(2) 125px width and 220px height
(3) 166px width and 455px height

I want all the images to resize to 100px width but the height adjusts
automatically.

Regards,

Stephen


Stephen:

Here's the code.

http://webbytedd.com/b/thumb/

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



Re: [PHP] Image Resizing

2008-12-21 Thread Gary Maddock-Greene

nice post Tedd and useful web site :)

-Gary

tedd tedd.sperl...@gmail.com wrote in message 
news:p06240802c573f5a71...@[192.168.1.101]...

At 12:38 PM -0800 12/20/08, Stephen Alistoun wrote:

Hi all,

What is the best way in PHP to Resize an Image to a specific width.

For Example I have images in the following sizes:

(1) 200px width and 350px height
(2) 125px width and 220px height
(3) 166px width and 455px height

I want all the images to resize to 100px width but the height adjusts
automatically.

Regards,

Stephen


Stephen:

Here's the code.

http://webbytedd.com/b/thumb/

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



Re: [PHP] Passing var from one page to itself

2008-12-21 Thread tedd

At 4:10 PM +1300 12/21/08, Aslan wrote:

Hey there,

I have a problem where I have a simple -script that I am  wanting to 
pass back to itself three times

1) Symptoms -  2) Troubleshooting questions 3) Answer to problem

-snip-

I have it currently all on one page, but it isn't quite what I was after
..
Any help would be appreciated!


Hi Aslan:

Keeping it all on one page (one script) is fine -- no problems with that.

Here's the technique I use.

$step = isset($__POST ['step']) ? $__POST ['step'] :1;

if($step == 1)
   {
   // do the first page stuff (Symptoms)
   // with a POST form that has an input type=hidden name=step value=1
   }

if($step == 2)
   {
   // do the second page stuff ( Troubleshooting questions)
   // with a POST form that has an input type=hidden name=step value=2
   }

if($step == 3)
   {
   // do the third page stuff (Answer to problem)
   // with a POST form that has an input type=hidden name=step value=3
   }

If you want to pass variables between pages (trips from client to the 
server nad back again), you have four options, namely: 1) 
writing/reading a file; 2) writing/reading a database entry; 3) 
passing via a POST/GET; 4) or using SESSIONS.


For most things, I prefer using POST/GET and/or SESSIONS. Try this format:

$var1 = isset($_POST['var1']) ? $_POST['var1'] : null;
$var2 = isset($_SESSION['var2']) ? $_SESSION['var2'] : null;

That's the way I pass data between client and server.

However, what you are describing sounds a bit like this:

http://webbytedd.com/b/exam/

With this example, I'm not passing anything to the server -- 
everything is kept client-side and is quick.


If interested, all the code is there.

Cheers,

tedd

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

[PHP] eof bof in php

2008-12-21 Thread Gary Maddock-Greene
Hi, I'm very new to php. Please can someone point me in the right direction? 
I want to display a message: 'No Products Found' if my search record set 
returns no value.


I think I need to be looking at this section of my code ...

$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);
?

Thanks

- Gary Maddock-Greene 



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



Re: [PHP] eof bof in php

2008-12-21 Thread Ashley Sheridan
On Sun, 2008-12-21 at 15:22 +, Gary Maddock-Greene wrote:
 Hi, I'm very new to php. Please can someone point me in the right direction? 
 I want to display a message: 'No Products Found' if my search record set 
 returns no value.
 
 I think I need to be looking at this section of my code ...
 
 $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);
 ?
 
 Thanks
 
 - Gary Maddock-Greene 
 
 
Can you not just use the $totalRows_rsSearch value inside of an if
statement?


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] eof bof in php

2008-12-21 Thread Gary Maddock-Greene

Thanks Ashley ... I have been trying that but I think my syntax id shot!!

?php
if ($totalRows_rsSearch=0)
echo Sorry no products were found;
else
echo h3Please click on a product for further information./h3
?
 !-- Product block start search results --
 ?php do { ?
 div class=productitemimg src=products?php echo 
$row_rsSearch['product_image']; ? /

   div class=text
 h3?php echo $row_rsSearch['product_name']; ?/h3
   p class=style1?php echo $row_rsSearch['product_subtitle']; 
?/p
   a href=products?php echo $row_rsSearch['product_url']; 
?View Product/a

 div class=clear/div
 /div div class=clear/div
  center
 /center
   /div
 ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?

--
- Gary Maddock-Greene
Ashley Sheridan a...@ashleysheridan.co.uk wrote in message 
news:1229873521.4229.6.ca...@localhost.localdomain...

On Sun, 2008-12-21 at 15:22 +, Gary Maddock-Greene wrote:
Hi, I'm very new to php. Please can someone point me in the right 
direction?

I want to display a message: 'No Products Found' if my search record set
returns no value.

I think I need to be looking at this section of my code ...

$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);
?

Thanks

- Gary Maddock-Greene



Can you not just use the $totalRows_rsSearch value inside of an if
statement?


Ash
www.ashleysheridan.co.uk




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



Re: [PHP] eof bof in php

2008-12-21 Thread Ashley Sheridan
On Sun, 2008-12-21 at 15:40 +, Gary Maddock-Greene wrote:
 Thanks Ashley ... I have been trying that but I think my syntax id shot!!
 
 ?php
  if ($totalRows_rsSearch=0)
 echo Sorry no products were found;
  else
 echo h3Please click on a product for further information./h3
 ?
   !-- Product block start search results --
   ?php do { ?
   div class=productitemimg src=products?php echo 
 $row_rsSearch['product_image']; ? /
 div class=text
   h3?php echo $row_rsSearch['product_name']; ?/h3
 p class=style1?php echo $row_rsSearch['product_subtitle']; 
 ?/p
 a href=products?php echo $row_rsSearch['product_url']; 
 ?View Product/a
   div class=clear/div
   /div div class=clear/div
center
   /center
 /div
   ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?
 
 -- 
 - Gary Maddock-Greene
 Ashley Sheridan a...@ashleysheridan.co.uk wrote in message 
 news:1229873521.4229.6.ca...@localhost.localdomain...
  On Sun, 2008-12-21 at 15:22 +, Gary Maddock-Greene wrote:
  Hi, I'm very new to php. Please can someone point me in the right 
  direction?
  I want to display a message: 'No Products Found' if my search record set
  returns no value.
 
  I think I need to be looking at this section of my code ...
 
  $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);
  ?
 
  Thanks
 
  - Gary Maddock-Greene
 
 
  Can you not just use the $totalRows_rsSearch value inside of an if
  statement?
 
 
  Ash
  www.ashleysheridan.co.uk
  
 
 
It might be because you're comparing the total to a string rather than a
number  if ($totalRows_rsSearch=0)

If you remove the quote marks, it should work. 


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] eof bof in php

2008-12-21 Thread Gary Maddock-Greene

I have tried that but to no avail :)

?php
if ($totalRows_rsSearch=0)
echo Sorry no products were found;
else


// All seems OK to here, then the syntax error unexpected T_VARIABLE 
appears



echo h3Please click on a product for further information./h3

?php do { ?
  div class=productitemimg src=products?php echo
$row_rsSearch['product_image']; ? /
div class=text
  h3?php echo $row_rsSearch['product_name']; ?/h3
p class=style1?php echo $row_rsSearch['product_subtitle'];
?/p
a href=products?php echo $row_rsSearch['product_url'];
?View Product/a
  div class=clear/div
  /div div class=clear/div
   center
  /center
/div
  ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?

--
- Gary Maddock-Greene
Ashley Sheridan a...@ashleysheridan.co.uk wrote in message 
news:1229875150.4229.9.ca...@localhost.localdomain...

On Sun, 2008-12-21 at 15:40 +, Gary Maddock-Greene wrote:

Thanks Ashley ... I have been trying that but I think my syntax id shot!!

?php
 if ($totalRows_rsSearch=0)
echo Sorry no products were found;
 else
echo h3Please click on a product for further information./h3
?
  !-- Product block start search results --
  ?php do { ?
  div class=productitemimg src=products?php echo
$row_rsSearch['product_image']; ? /
div class=text
  h3?php echo $row_rsSearch['product_name']; ?/h3
p class=style1?php echo 
$row_rsSearch['product_subtitle'];

?/p
a href=products?php echo $row_rsSearch['product_url'];
?View Product/a
  div class=clear/div
  /div div class=clear/div
   center
  /center
/div
  ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?

--
- Gary Maddock-Greene
Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
news:1229873521.4229.6.ca...@localhost.localdomain...
 On Sun, 2008-12-21 at 15:22 +, Gary Maddock-Greene wrote:
 Hi, I'm very new to php. Please can someone point me in the right
 direction?
 I want to display a message: 'No Products Found' if my search record 
 set

 returns no value.

 I think I need to be looking at this section of my code ...

 $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);
 ?

 Thanks

 - Gary Maddock-Greene


 Can you not just use the $totalRows_rsSearch value inside of an if
 statement?


 Ash
 www.ashleysheridan.co.uk




It might be because you're comparing the total to a string rather than a
number  if ($totalRows_rsSearch=0)

If you remove the quote marks, it should work.


Ash
www.ashleysheridan.co.uk




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



Re: [PHP] eof bof in php

2008-12-21 Thread Ashley Sheridan
On Sun, 2008-12-21 at 16:22 +, Gary Maddock-Greene wrote:
 I have tried that but to no avail :)
 
 ?php
  if ($totalRows_rsSearch=0)
  echo Sorry no products were found;
  else
 
 
  // All seems OK to here, then the syntax error unexpected T_VARIABLE 
 appears
 
 
 echo h3Please click on a product for further information./h3
 
 ?php do { ?
div class=productitemimg src=products?php echo
  $row_rsSearch['product_image']; ? /
  div class=text
h3?php echo $row_rsSearch['product_name']; ?/h3
  p class=style1?php echo $row_rsSearch['product_subtitle'];
  ?/p
  a href=products?php echo $row_rsSearch['product_url'];
  ?View Product/a
div class=clear/div
/div div class=clear/div
 center
/center
  /div
?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?
 
 -- 
 - Gary Maddock-Greene
 Ashley Sheridan a...@ashleysheridan.co.uk wrote in message 
 news:1229875150.4229.9.ca...@localhost.localdomain...
  On Sun, 2008-12-21 at 15:40 +, Gary Maddock-Greene wrote:
  Thanks Ashley ... I have been trying that but I think my syntax id shot!!
 
  ?php
   if ($totalRows_rsSearch=0)
  echo Sorry no products were found;
   else
  echo h3Please click on a product for further information./h3
  ?
!-- Product block start search results --
?php do { ?
div class=productitemimg src=products?php echo
  $row_rsSearch['product_image']; ? /
  div class=text
h3?php echo $row_rsSearch['product_name']; ?/h3
  p class=style1?php echo 
  $row_rsSearch['product_subtitle'];
  ?/p
  a href=products?php echo $row_rsSearch['product_url'];
  ?View Product/a
div class=clear/div
/div div class=clear/div
 center
/center
  /div
?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?
 
  -- 
  - Gary Maddock-Greene
  Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
  news:1229873521.4229.6.ca...@localhost.localdomain...
   On Sun, 2008-12-21 at 15:22 +, Gary Maddock-Greene wrote:
   Hi, I'm very new to php. Please can someone point me in the right
   direction?
   I want to display a message: 'No Products Found' if my search record 
   set
   returns no value.
  
   I think I need to be looking at this section of my code ...
  
   $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);
   ?
  
   Thanks
  
   - Gary Maddock-Greene
  
  
   Can you not just use the $totalRows_rsSearch value inside of an if
   statement?
  
  
   Ash
   www.ashleysheridan.co.uk
  
 
 
  It might be because you're comparing the total to a string rather than a
  number  if ($totalRows_rsSearch=0)
 
  If you remove the quote marks, it should work.
 
 
  Ash
  www.ashleysheridan.co.uk
  
 
 
Just spotted that you've omitted the semicolon from the second echo
statement as well.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] eof bof in php

2008-12-21 Thread Anthony Gentile
if (0 == $totalRows_rsSearch) {
echo Sorry no products were found;
} else

Anthony Gentile



On Sun, Dec 21, 2008 at 11:22 AM, Gary Maddock-Greene 
g...@maddock-greene.co.uk wrote:

 I have tried that but to no avail :)

 ?php
 if ($totalRows_rsSearch=0)
 echo Sorry no products were found;
 else


 // All seems OK to here, then the syntax error unexpected T_VARIABLE
 appears


 echo h3Please click on a product for further information./h3

 ?php do { ?
  div class=productitemimg src=products?php echo
 $row_rsSearch['product_image']; ? /
div class=text
  h3?php echo $row_rsSearch['product_name']; ?/h3
p class=style1?php echo $row_rsSearch['product_subtitle'];
 ?/p
a href=products?php echo $row_rsSearch['product_url'];
 ?View Product/a
  div class=clear/div
  /div div class=clear/div
   center
  /center
/div
  ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?

 --
 - Gary Maddock-Greene
 Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
 news:1229875150.4229.9.ca...@localhost.localdomain...

  On Sun, 2008-12-21 at 15:40 +, Gary Maddock-Greene wrote:

 Thanks Ashley ... I have been trying that but I think my syntax id shot!!

 ?php
  if ($totalRows_rsSearch=0)
 echo Sorry no products were found;
  else
 echo h3Please click on a product for further information./h3
 ?
  !-- Product block start search results --
  ?php do { ?
  div class=productitemimg src=products?php echo
 $row_rsSearch['product_image']; ? /
div class=text
  h3?php echo $row_rsSearch['product_name']; ?/h3
p class=style1?php echo
 $row_rsSearch['product_subtitle'];
 ?/p
a href=products?php echo $row_rsSearch['product_url'];
 ?View Product/a
  div class=clear/div
  /div div class=clear/div
   center
  /center
/div
  ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?

 --
 - Gary Maddock-Greene
 Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
 news:1229873521.4229.6.ca...@localhost.localdomain...
  On Sun, 2008-12-21 at 15:22 +, Gary Maddock-Greene wrote:
  Hi, I'm very new to php. Please can someone point me in the right
  direction?
  I want to display a message: 'No Products Found' if my search record
  set
  returns no value.
 
  I think I need to be looking at this section of my code ...
 
  $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);
  ?
 
  Thanks
 
  - Gary Maddock-Greene
 
 
  Can you not just use the $totalRows_rsSearch value inside of an if
  statement?
 
 
  Ash
  www.ashleysheridan.co.uk
 


  It might be because you're comparing the total to a string rather than a
 number  if ($totalRows_rsSearch=0)

 If you remove the quote marks, it should work.


 Ash
 www.ashleysheridan.co.uk



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




Re: [PHP] eof bof in php

2008-12-21 Thread Ashley Sheridan
On Sun, 2008-12-21 at 11:39 -0500, Anthony Gentile wrote:
 if (0 == $totalRows_rsSearch) {
 echo Sorry no products were found;
 } else
 
 Anthony Gentile
 
 
 
 On Sun, Dec 21, 2008 at 11:22 AM, Gary Maddock-Greene 
 g...@maddock-greene.co.uk wrote:
 
  I have tried that but to no avail :)
 
  ?php
  if ($totalRows_rsSearch=0)
  echo Sorry no products were found;
  else
 
 
  // All seems OK to here, then the syntax error unexpected T_VARIABLE
  appears
 
 
  echo h3Please click on a product for further information./h3
 
  ?php do { ?
   div class=productitemimg src=products?php echo
  $row_rsSearch['product_image']; ? /
 div class=text
   h3?php echo $row_rsSearch['product_name']; ?/h3
 p class=style1?php echo $row_rsSearch['product_subtitle'];
  ?/p
 a href=products?php echo $row_rsSearch['product_url'];
  ?View Product/a
   div class=clear/div
   /div div class=clear/div
center
   /center
 /div
   ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?
 
  --
  - Gary Maddock-Greene
  Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
  news:1229875150.4229.9.ca...@localhost.localdomain...
 
   On Sun, 2008-12-21 at 15:40 +, Gary Maddock-Greene wrote:
 
  Thanks Ashley ... I have been trying that but I think my syntax id shot!!
 
  ?php
   if ($totalRows_rsSearch=0)
  echo Sorry no products were found;
   else
  echo h3Please click on a product for further information./h3
  ?
   !-- Product block start search results --
   ?php do { ?
   div class=productitemimg src=products?php echo
  $row_rsSearch['product_image']; ? /
 div class=text
   h3?php echo $row_rsSearch['product_name']; ?/h3
 p class=style1?php echo
  $row_rsSearch['product_subtitle'];
  ?/p
 a href=products?php echo $row_rsSearch['product_url'];
  ?View Product/a
   div class=clear/div
   /div div class=clear/div
center
   /center
 /div
   ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?
 
  --
  - Gary Maddock-Greene
  Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
  news:1229873521.4229.6.ca...@localhost.localdomain...
   On Sun, 2008-12-21 at 15:22 +, Gary Maddock-Greene wrote:
   Hi, I'm very new to php. Please can someone point me in the right
   direction?
   I want to display a message: 'No Products Found' if my search record
   set
   returns no value.
  
   I think I need to be looking at this section of my code ...
  
   $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);
   ?
  
   Thanks
  
   - Gary Maddock-Greene
  
  
   Can you not just use the $totalRows_rsSearch value inside of an if
   statement?
  
  
   Ash
   www.ashleysheridan.co.uk
  
 
 
   It might be because you're comparing the total to a string rather than a
  number  if ($totalRows_rsSearch=0)
 
  If you remove the quote marks, it should work.
 
 
  Ash
  www.ashleysheridan.co.uk
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
D'oh, not sure how I missed that one too, the double ==. No wonder it
wasn't working.


Ash
www.ashleysheridan.co.uk


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



[PHP] Create PHP form from MySQL table structure

2008-12-21 Thread R B MacGregor
Hi folks

Anybody got any recommendations for a utility which would create a quick head 
start by creating the php/html code for a basic form using the field structure 
of a MySQL table ?

Thanks for any suggestions.

-- 
Ronnie MacGregor
Scotland

Ronnie at
dBASEdeveloper
dot co dot uk

www.dBASEdeveloper.co.uk




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



Re: [PHP] Re: imap_rfc822_parse_adrlist problem

2008-12-21 Thread Manuel Lemos
Hello,

on 12/21/2008 11:12 AM Ben Stuyts said the following:
 Since upgrading to php 5.2.8 I have a problem with
 imap_rfc822_parse_adrlist. When I run the example given on the manual
 page at http://nl3.php.net/imap_rfc822_parse_adrlist:
 ...
 So the host part isn't filled in correctly. I have verified this on two
 FreeBSD 7 machines. On an older FreeBSD 5 machine with php4 this works
 fine. Before the update, I was running php 5.2.6 and there was no
 problem either. Any ideas?

 Sometime ago I decided to not use IMAP library functions to parse e-mail
 addresses because it was not handling all sorts of addresses as it
 should.
 
 Well, yeah, ok, I read about the problems imap_rfc822_parse_adrlist()
 has, but shouldn't it just work at least as advertized in the manual?
 Plus, this is breaking an existing application (Twiggi).

PHP always had backwards incompatibility breaking problems with new
releases. That is why PHP 5 took time to be adopted. Actuall, most ISP
were sort of forced to upgrade because the announcement of the end of
support to PHP 4 versions.

Anyway, if you found a bug, you only need to report it to bugs.php.net
to have it checked and hopefully fixed. Since it is related with an
external library, maybe it is not PHP fault.

PHP has a extensive test suite but I guess you either found a case that
is not well tested or it is not understood as a bug.


 Nowadays I use an e-mail address parser class written in pure PHP that
 comes with this MIME parser class:

 http://www.phpclasses.org/mimeparser
 
 Thanks, I'll have a look at that.


-- 

Regards,
Manuel Lemos

Find and post PHP jobs
http://www.phpclasses.org/jobs/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

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



Re: [PHP] Create PHP form from MySQL table structure

2008-12-21 Thread tedd

At 10:35 AM + 12/21/08, R B MacGregor wrote:

Hi folks

Anybody got any recommendations for a utility which would create a quick head
start by creating the php/html code for a basic form using the field structure
of a MySQL table ?

Thanks for any suggestions.

--
Ronnie MacGregor
Scotland

Ronnie at
dBASEdeveloper
dot co dot uk



Interesting.

I am sure that one can write a script to find all the fields in a 
table and create a form from that. However, I don't know of any 
utility that does that.


Hope that helps,

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



Re: [PHP] eof bof in php

2008-12-21 Thread Gary Maddock-Greene

Thanks guys .. I can get this part working great ..

?php
if (0 == $totalRows_rsSearch) {
echo h3Sorry no products were found/h3;
} else
echo h3Please click on a product for further information./h3
?

But I want to add the following so that only the products table appears when 
product are present. I cannot seem to add this code into the above after the 
echo h3Please click on a product for further information./h3. I can't 
get the syntax right ...


I appreciate everyones help

--
- Gary Maddock-Greene
Ashley Sheridan a...@ashleysheridan.co.uk wrote in message 
news:1229878234.4229.12.ca...@localhost.localdomain...

On Sun, 2008-12-21 at 11:39 -0500, Anthony Gentile wrote:

if (0 == $totalRows_rsSearch) {
echo Sorry no products were found;
} else

Anthony Gentile



On Sun, Dec 21, 2008 at 11:22 AM, Gary Maddock-Greene 
g...@maddock-greene.co.uk wrote:

 I have tried that but to no avail :)

 ?php
 if ($totalRows_rsSearch=0)
 echo Sorry no products were found;
 else


 // All seems OK to here, then the syntax error unexpected T_VARIABLE
 appears


 echo h3Please click on a product for further information./h3

 ?php do { ?
  div class=productitemimg src=products?php echo
 $row_rsSearch['product_image']; ? /
div class=text
  h3?php echo $row_rsSearch['product_name']; ?/h3
p class=style1?php echo 
 $row_rsSearch['product_subtitle'];

 ?/p
a href=products?php echo $row_rsSearch['product_url'];
 ?View Product/a
  div class=clear/div
  /div div class=clear/div
   center
  /center
/div
  ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?

 --
 - Gary Maddock-Greene
 Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
 news:1229875150.4229.9.ca...@localhost.localdomain...

  On Sun, 2008-12-21 at 15:40 +, Gary Maddock-Greene wrote:

 Thanks Ashley ... I have been trying that but I think my syntax id 
 shot!!


 ?php
  if ($totalRows_rsSearch=0)
 echo Sorry no products were found;
  else
 echo h3Please click on a product for further information./h3
 ?
  !-- Product block start search results --
  ?php do { ?
  div class=productitemimg src=products?php echo
 $row_rsSearch['product_image']; ? /
div class=text
  h3?php echo $row_rsSearch['product_name']; ?/h3
p class=style1?php echo
 $row_rsSearch['product_subtitle'];
 ?/p
a href=products?php echo $row_rsSearch['product_url'];
 ?View Product/a
  div class=clear/div
  /div div class=clear/div
   center
  /center
/div
  ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?

 --
 - Gary Maddock-Greene
 Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
 news:1229873521.4229.6.ca...@localhost.localdomain...
  On Sun, 2008-12-21 at 15:22 +, Gary Maddock-Greene wrote:
  Hi, I'm very new to php. Please can someone point me in the right
  direction?
  I want to display a message: 'No Products Found' if my search 
  record

  set
  returns no value.
 
  I think I need to be looking at this section of my code ...
 
  $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);
  ?
 
  Thanks
 
  - Gary Maddock-Greene
 
 
  Can you not just use the $totalRows_rsSearch value inside of an if
  statement?
 
 
  Ash
  www.ashleysheridan.co.uk
 


  It might be because you're comparing the total to a string rather 
 than a

 number  if ($totalRows_rsSearch=0)

 If you remove the quote marks, it should work.


 Ash
 www.ashleysheridan.co.uk



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



D'oh, not sure how I missed that one too, the double ==. No wonder it
wasn't working.


Ash
www.ashleysheridan.co.uk




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



Re: [PHP] Create PHP form from MySQL table structure

2008-12-21 Thread Bassel Safadi
On Sun, Dec 21, 2008 at 7:24 PM, tedd tedd.sperl...@gmail.com wrote:

 At 10:35 AM + 12/21/08, R B MacGregor wrote:

 Hi folks

 Anybody got any recommendations for a utility which would create a quick
 head
 start by creating the php/html code for a basic form using the field
 structure
 of a MySQL table ?

 Thanks for any suggestions.

 --
 Ronnie MacGregor
 Scotland

 Ronnie at
 dBASEdeveloper
 dot co dot uk



 Interesting.

 I am sure that one can write a script to find all the fields in a table and
 create a form from that. However, I don't know of any utility that does
 that.

 Hope that helps,

 tedd



I wrote a class for my upcoming opensource cms ( aikicms ) , that can handle
an array of added value description of a db table, and convert it into forms
for inserting, and editing.

the array looks like this:


 $insertArray= array(
 tablename = aiki_something,
 pkey = id,
 selection1 = cityid:NAME:aikiads_cities:id:cities,  //values form
other table: aikiads_cities
 textinput1 = name:NAME,
 textblock = bodytext:NAME,
 upload =
filename:NAME:jpg:resize:640|n_|75|s_:/home/paintings:/home/paintings/s_,
 staticselect = staticname:NAME:letters,
 staticselect = staticname:NAME:date_years:2002-2008,
 imagefolderupload =
filedname:NAME:jpg:resize:640|n_|75|s_:/home/paintings:/home/paintings/s_,
 );

the values of this method instead of just walking throw each filed and
putting a text block for it, that the class can automatically generate
upload forms with image resizing and stored procedures of linked tables
inside mysql..

I think you'll understand what I mean by just looking to the array, the code
will be available soon under GPL,
if anyone is interesting I can send the beta class source for further
improvement,

 maybe adding a function that can find each field of a table and Hey that's
a text filed just add:
 textinput1 = name:NAME,

then the class will build the form for you


Re: [PHP] eof bof in php

2008-12-21 Thread Anthony Gentile
...missing semicolon and some brackets.

?php
if (0 == $totalRows_rsSearch) {
echo h3Sorry no products were found/h3;
} else {
echo h3Please click on a product for further information./h3;
}
?

If there is more code you can show by perhaps pasting here:
http://pastebin.redlinktech.com
We can help with further syntax problems.

Anthony Gentile



On Sun, Dec 21, 2008 at 12:33 PM, Gary Maddock-Greene 
g...@maddock-greene.co.uk wrote:

 Thanks guys .. I can get this part working great ..

 ?php
 if (0 == $totalRows_rsSearch) {
 echo h3Sorry no products were found/h3;
 } else
 echo h3Please click on a product for further information./h3
 ?

 But I want to add the following so that only the products table appears
 when product are present. I cannot seem to add this code into the above
 after the echo h3Please click on a product for further
 information./h3. I can't get the syntax right ...

 I appreciate everyones help

 --
 - Gary Maddock-Greene
 Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
 news:1229878234.4229.12.ca...@localhost.localdomain...

  On Sun, 2008-12-21 at 11:39 -0500, Anthony Gentile wrote:

 if (0 == $totalRows_rsSearch) {
 echo Sorry no products were found;
 } else

 Anthony Gentile



 On Sun, Dec 21, 2008 at 11:22 AM, Gary Maddock-Greene 
 g...@maddock-greene.co.uk wrote:

  I have tried that but to no avail :)
 
  ?php
  if ($totalRows_rsSearch=0)
  echo Sorry no products were found;
  else
 
 
  // All seems OK to here, then the syntax error unexpected T_VARIABLE
  appears
 
 
  echo h3Please click on a product for further information./h3
 
  ?php do { ?
   div class=productitemimg src=products?php echo
  $row_rsSearch['product_image']; ? /
 div class=text
   h3?php echo $row_rsSearch['product_name']; ?/h3
 p class=style1?php echo 
 $row_rsSearch['product_subtitle'];
  ?/p
 a href=products?php echo $row_rsSearch['product_url'];
  ?View Product/a
   div class=clear/div
   /div div class=clear/div
center
   /center
 /div
   ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?
 
  --
  - Gary Maddock-Greene
  Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
  news:1229875150.4229.9.ca...@localhost.localdomain...
 
   On Sun, 2008-12-21 at 15:40 +, Gary Maddock-Greene wrote:
 
  Thanks Ashley ... I have been trying that but I think my syntax id
  shot!!
 
  ?php
   if ($totalRows_rsSearch=0)
  echo Sorry no products were found;
   else
  echo h3Please click on a product for further information./h3
  ?
   !-- Product block start search results --
   ?php do { ?
   div class=productitemimg src=products?php echo
  $row_rsSearch['product_image']; ? /
 div class=text
   h3?php echo $row_rsSearch['product_name']; ?/h3
 p class=style1?php echo
  $row_rsSearch['product_subtitle'];
  ?/p
 a href=products?php echo $row_rsSearch['product_url'];
  ?View Product/a
   div class=clear/div
   /div div class=clear/div
center
   /center
 /div
   ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?
 
  --
  - Gary Maddock-Greene
  Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
  news:1229873521.4229.6.ca...@localhost.localdomain...
   On Sun, 2008-12-21 at 15:22 +, Gary Maddock-Greene wrote:
   Hi, I'm very new to php. Please can someone point me in the right
   direction?
   I want to display a message: 'No Products Found' if my search 
  record
   set
   returns no value.
  
   I think I need to be looking at this section of my code ...
  
   $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);
   ?
  
   Thanks
  
   - Gary Maddock-Greene
  
  
   Can you not just use the $totalRows_rsSearch value inside of an if
   statement?
  
  
   Ash
   www.ashleysheridan.co.uk
  
 
 
   It might be because you're comparing the total to a string rather
  than a
  number  if ($totalRows_rsSearch=0)
 
  If you remove the quote marks, it should work.
 
 
  Ash
  www.ashleysheridan.co.uk
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 

 D'oh, not sure how I missed that one too, the double ==. No wonder it
 wasn't working.


 Ash
 www.ashleysheridan.co.uk



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




Re: [PHP] eof bof in php

2008-12-21 Thread Gary Maddock-Greene
I've corrected those errors thanks but how do I insert this code as the else 
statement?


?php do { ?
  div class=productitemimg src=products?php echo
$row_rsSearch['product_image']; ? /
div class=text
  h3?php echo $row_rsSearch['product_name']; ?/h3
p class=style1?php echo $row_rsSearch['product_subtitle'];
?/p
a href=products?php echo $row_rsSearch['product_url'];
?View Product/a
  div class=clear/div
  /div div class=clear/div
   center
  /center
/div
  ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?

--
- Gary Maddock-Greene
Anthony Gentile asgent...@gmail.com wrote in message 
news:2ce4207d0812210959k3491690ctbc4f0dbf971ac...@mail.gmail.com...

...missing semicolon and some brackets.

?php
if (0 == $totalRows_rsSearch) {
echo h3Sorry no products were found/h3;
} else {
echo h3Please click on a product for further information./h3;
}
?

If there is more code you can show by perhaps pasting here:
http://pastebin.redlinktech.com
We can help with further syntax problems.

Anthony Gentile



On Sun, Dec 21, 2008 at 12:33 PM, Gary Maddock-Greene 
g...@maddock-greene.co.uk wrote:


Thanks guys .. I can get this part working great ..

?php
if (0 == $totalRows_rsSearch) {
echo h3Sorry no products were found/h3;
} else
echo h3Please click on a product for further information./h3
?

But I want to add the following so that only the products table appears
when product are present. I cannot seem to add this code into the above
after the echo h3Please click on a product for further
information./h3. I can't get the syntax right ...

I appreciate everyones help

--
- Gary Maddock-Greene
Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
news:1229878234.4229.12.ca...@localhost.localdomain...

 On Sun, 2008-12-21 at 11:39 -0500, Anthony Gentile wrote:



if (0 == $totalRows_rsSearch) {
echo Sorry no products were found;
} else

Anthony Gentile



On Sun, Dec 21, 2008 at 11:22 AM, Gary Maddock-Greene 
g...@maddock-greene.co.uk wrote:

 I have tried that but to no avail :)

 ?php
 if ($totalRows_rsSearch=0)
 echo Sorry no products were found;
 else


 // All seems OK to here, then the syntax error unexpected T_VARIABLE
 appears


 echo h3Please click on a product for further information./h3

 ?php do { ?
  div class=productitemimg src=products?php echo
 $row_rsSearch['product_image']; ? /
div class=text
  h3?php echo $row_rsSearch['product_name']; ?/h3
p class=style1?php echo 
$row_rsSearch['product_subtitle'];
 ?/p
a href=products?php echo $row_rsSearch['product_url'];
 ?View Product/a
  div class=clear/div
  /div div class=clear/div
   center
  /center
/div
  ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?

 --
 - Gary Maddock-Greene
 Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
 news:1229875150.4229.9.ca...@localhost.localdomain...

  On Sun, 2008-12-21 at 15:40 +, Gary Maddock-Greene wrote:

 Thanks Ashley ... I have been trying that but I think my syntax id
 shot!!

 ?php
  if ($totalRows_rsSearch=0)
 echo Sorry no products were found;
  else
 echo h3Please click on a product for further information./h3
 ?
  !-- Product block start search results --
  ?php do { ?
  div class=productitemimg src=products?php echo
 $row_rsSearch['product_image']; ? /
div class=text
  h3?php echo $row_rsSearch['product_name']; ?/h3
p class=style1?php echo
 $row_rsSearch['product_subtitle'];
 ?/p
a href=products?php echo 
 $row_rsSearch['product_url'];

 ?View Product/a
  div class=clear/div
  /div div class=clear/div
   center
  /center
/div
  ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?

 --
 - Gary Maddock-Greene
 Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
 news:1229873521.4229.6.ca...@localhost.localdomain...
  On Sun, 2008-12-21 at 15:22 +, Gary Maddock-Greene wrote:
  Hi, I'm very new to php. Please can someone point me in the 
  right

  direction?
  I want to display a message: 'No Products Found' if my search 
   

 record
  set
  returns no value.
 
  I think I need to be looking at this section of my code ...
 
  $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);
  ?
 
  Thanks
 
  - Gary Maddock-Greene
 
 
  Can you not just use the $totalRows_rsSearch value inside of an 
  if

  statement?
 
 
  Ash
  www.ashleysheridan.co.uk
 


  It might be because you're comparing the total to a string rather
 than a
 number  if ($totalRows_rsSearch=0)

 If you remove the quote marks, it should work.


 Ash
 www.ashleysheridan.co.uk



 --
 

Re: [PHP] eof bof in php

2008-12-21 Thread Anthony Gentile
?php
if (0 == $totalRows_rsSearch) {
echo h3Sorry no products were found/h3;
} else {
echo h3Please 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;
}

}
?

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


On Sun, Dec 21, 2008 at 1:07 PM, Gary Maddock-Greene 
g...@maddock-greene.co.uk wrote:

 I've corrected those errors thanks but how do I insert this code as the
 else statement?

 ?php do { ?
  div class=productitemimg src=products?php echo
 $row_rsSearch['product_image']; ? /
div class=text
  h3?php echo $row_rsSearch['product_name']; ?/h3
p class=style1?php echo $row_rsSearch['product_subtitle'];
 ?/p
a href=products?php echo $row_rsSearch['product_url'];
 ?View Product/a
  div class=clear/div
  /div div class=clear/div
   center
  /center
/div
  ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?

 --
 - Gary Maddock-Greene
 Anthony Gentile asgent...@gmail.com wrote in message
 news:2ce4207d0812210959k3491690ctbc4f0dbf971ac...@mail.gmail.com...

  ...missing semicolon and some brackets.

 ?php
 if (0 == $totalRows_rsSearch) {
 echo h3Sorry no products were found/h3;
 } else {
 echo h3Please click on a product for further information./h3;
 }
 ?

 If there is more code you can show by perhaps pasting here:
 http://pastebin.redlinktech.com
 We can help with further syntax problems.

 Anthony Gentile



 On Sun, Dec 21, 2008 at 12:33 PM, Gary Maddock-Greene 
 g...@maddock-greene.co.uk wrote:

  Thanks guys .. I can get this part working great ..

 ?php
 if (0 == $totalRows_rsSearch) {
 echo h3Sorry no products were found/h3;
 } else
 echo h3Please click on a product for further information./h3
 ?

 But I want to add the following so that only the products table appears
 when product are present. I cannot seem to add this code into the above
 after the echo h3Please click on a product for further
 information./h3. I can't get the syntax right ...

 I appreciate everyones help

 --
 - Gary Maddock-Greene
 Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
 news:1229878234.4229.12.ca...@localhost.localdomain...

  On Sun, 2008-12-21 at 11:39 -0500, Anthony Gentile wrote:


  if (0 == $totalRows_rsSearch) {
 echo Sorry no products were found;
 } else

 Anthony Gentile



 On Sun, Dec 21, 2008 at 11:22 AM, Gary Maddock-Greene 
 g...@maddock-greene.co.uk wrote:

  I have tried that but to no avail :)
 
  ?php
  if ($totalRows_rsSearch=0)
  echo Sorry no products were found;
  else
 
 
  // All seems OK to here, then the syntax error unexpected T_VARIABLE
  appears
 
 
  echo h3Please click on a product for further information./h3
 
  ?php do { ?
   div class=productitemimg src=products?php echo
  $row_rsSearch['product_image']; ? /
 div class=text
   h3?php echo $row_rsSearch['product_name']; ?/h3
 p class=style1?php echo 
 $row_rsSearch['product_subtitle'];
  ?/p
 a href=products?php echo $row_rsSearch['product_url'];
  ?View Product/a
   div class=clear/div
   /div div class=clear/div
center
   /center
 /div
   ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?
 
  --
  - Gary Maddock-Greene
  Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
  news:1229875150.4229.9.ca...@localhost.localdomain...
 
   On Sun, 2008-12-21 at 15:40 +, Gary Maddock-Greene wrote:
 
  Thanks Ashley ... I have been trying that but I think my syntax id
  shot!!
 
  ?php
   if ($totalRows_rsSearch=0)
  echo Sorry no products were found;
   else
  echo h3Please click on a product for further information./h3
  ?
   !-- Product block start search results --
   ?php do { ?
   div class=productitemimg src=products?php echo
  $row_rsSearch['product_image']; ? /
 div class=text
   h3?php echo $row_rsSearch['product_name']; ?/h3
 p class=style1?php echo
  $row_rsSearch['product_subtitle'];
  ?/p
 a href=products?php echo 
 $row_rsSearch['product_url'];
  ?View Product/a
   div class=clear/div
   /div div class=clear/div
center
   /center
 /div
   ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?
 
  --
  - Gary Maddock-Greene
  Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
  

Re: [PHP] eof bof in php

2008-12-21 Thread Anthony Gentile
err forgot the closing  in img src=\products\.
should look like img src=\products\.
Anthony Gentile
Cell: 704.657.8550

Diese E-Mail ist vertraulich. Wenn Sie nicht der rechtmaessige Empfaenger
sind, duerfen Sie den Inhalt weder kopieren noch verbreiten oder benutzen.
Sollten Sie diese E-Mail versehentlich erhalten haben, senden Sie diese
bitte an uns zurueck und loeschen Sie sie anschliessend.

This email is confidential. If you are not the intended recipient, you must
not copy, disclose or use its contents. If you have received it in error,
please inform us immediately by return email and delete the document.


On Sun, Dec 21, 2008 at 1:21 PM, Anthony Gentile asgent...@gmail.comwrote:

 ?php
 if (0 == $totalRows_rsSearch) {
 echo h3Sorry no products were found/h3;
 } else {
 echo h3Please 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;
 }

 }
 ?

 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



 On Sun, Dec 21, 2008 at 1:07 PM, Gary Maddock-Greene 
 g...@maddock-greene.co.uk wrote:

 I've corrected those errors thanks but how do I insert this code as the
 else statement?

 ?php do { ?
  div class=productitemimg src=products?php echo
 $row_rsSearch['product_image']; ? /
div class=text
  h3?php echo $row_rsSearch['product_name']; ?/h3
p class=style1?php echo $row_rsSearch['product_subtitle'];
 ?/p
a href=products?php echo $row_rsSearch['product_url'];
 ?View Product/a
  div class=clear/div
  /div div class=clear/div
   center
  /center
/div
  ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?

 --
 - Gary Maddock-Greene
 Anthony Gentile asgent...@gmail.com wrote in message
 news:2ce4207d0812210959k3491690ctbc4f0dbf971ac...@mail.gmail.com...

  ...missing semicolon and some brackets.

 ?php
 if (0 == $totalRows_rsSearch) {
 echo h3Sorry no products were found/h3;
 } else {
 echo h3Please click on a product for further information./h3;
 }
 ?

 If there is more code you can show by perhaps pasting here:
 http://pastebin.redlinktech.com
 We can help with further syntax problems.

 Anthony Gentile



 On Sun, Dec 21, 2008 at 12:33 PM, Gary Maddock-Greene 
 g...@maddock-greene.co.uk wrote:

  Thanks guys .. I can get this part working great ..

 ?php
 if (0 == $totalRows_rsSearch) {
 echo h3Sorry no products were found/h3;
 } else
 echo h3Please click on a product for further information./h3
 ?

 But I want to add the following so that only the products table appears
 when product are present. I cannot seem to add this code into the above
 after the echo h3Please click on a product for further
 information./h3. I can't get the syntax right ...

 I appreciate everyones help

 --
 - Gary Maddock-Greene
 Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
 news:1229878234.4229.12.ca...@localhost.localdomain...

  On Sun, 2008-12-21 at 11:39 -0500, Anthony Gentile wrote:


  if (0 == $totalRows_rsSearch) {
 echo Sorry no products were found;
 } else

 Anthony Gentile



 On Sun, Dec 21, 2008 at 11:22 AM, Gary Maddock-Greene 
 g...@maddock-greene.co.uk wrote:

  I have tried that but to no avail :)
 
  ?php
  if ($totalRows_rsSearch=0)
  echo Sorry no products were found;
  else
 
 
  // All seems OK to here, then the syntax error unexpected T_VARIABLE
  appears
 
 
  echo h3Please click on a product for further information./h3
 
  ?php do { ?
   div class=productitemimg src=products?php echo
  $row_rsSearch['product_image']; ? /
 div class=text
   h3?php echo $row_rsSearch['product_name']; ?/h3
 p class=style1?php echo 
 $row_rsSearch['product_subtitle'];
  ?/p
 a href=products?php echo $row_rsSearch['product_url'];
  ?View Product/a
   div class=clear/div
   /div div class=clear/div
center
   /center
 /div
   ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?
 
  --
  - Gary Maddock-Greene
  Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
  news:1229875150.4229.9.ca...@localhost.localdomain...
 
   On Sun, 2008-12-21 at 15:40 +, Gary Maddock-Greene wrote:
 
  Thanks Ashley ... I have been trying that but I think my syntax id
  shot!!
 
  ?php
   if ($totalRows_rsSearch=0)
  echo Sorry no products were found;
   else
  echo h3Please click on a product for further 

Re: [PHP] eof bof in php

2008-12-21 Thread Gary Maddock-Greene
That's got it thanks Anthony. I love when you learn something. It was the 
back slash \ preceeding the 's in my html that I wasn't aware of. Now I 
know they are needed if using  in your code.


Thank you so much for your help.



--
- Gary Maddock-Greene
Anthony Gentile asgent...@gmail.com wrote in message 
news:2ce4207d0812211021g215d5346wb0afcedf039ef...@mail.gmail.com...

?php
if (0 == $totalRows_rsSearch) {
echo h3Sorry no products were found/h3;
} else {
echo h3Please 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;
}

}
?

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


On Sun, Dec 21, 2008 at 1:07 PM, Gary Maddock-Greene 
g...@maddock-greene.co.uk wrote:


I've corrected those errors thanks but how do I insert this code as the
else statement?

?php do { ?
 div class=productitemimg src=products?php echo
$row_rsSearch['product_image']; ? /
   div class=text
 h3?php echo $row_rsSearch['product_name']; ?/h3
   p class=style1?php echo 
$row_rsSearch['product_subtitle'];

?/p
   a href=products?php echo $row_rsSearch['product_url'];
?View Product/a
 div class=clear/div
 /div div class=clear/div
  center
 /center
   /div
 ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?

--
- Gary Maddock-Greene
Anthony Gentile asgent...@gmail.com wrote in message
news:2ce4207d0812210959k3491690ctbc4f0dbf971ac...@mail.gmail.com...

 ...missing semicolon and some brackets.


?php
if (0 == $totalRows_rsSearch) {
echo h3Sorry no products were found/h3;
} else {
echo h3Please click on a product for further information./h3;
}
?

If there is more code you can show by perhaps pasting here:
http://pastebin.redlinktech.com
We can help with further syntax problems.

Anthony Gentile



On Sun, Dec 21, 2008 at 12:33 PM, Gary Maddock-Greene 
g...@maddock-greene.co.uk wrote:

 Thanks guys .. I can get this part working great ..


?php
if (0 == $totalRows_rsSearch) {
echo h3Sorry no products were found/h3;
} else
echo h3Please click on a product for further information./h3
?

But I want to add the following so that only the products table appears
when product are present. I cannot seem to add this code into the above
after the echo h3Please click on a product for further
information./h3. I can't get the syntax right ...

I appreciate everyones help

--
- Gary Maddock-Greene
Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
news:1229878234.4229.12.ca...@localhost.localdomain...

 On Sun, 2008-12-21 at 11:39 -0500, Anthony Gentile wrote:



 if (0 == $totalRows_rsSearch) {

echo Sorry no products were found;
} else

Anthony Gentile



On Sun, Dec 21, 2008 at 11:22 AM, Gary Maddock-Greene 
g...@maddock-greene.co.uk wrote:

 I have tried that but to no avail :)

 ?php
 if ($totalRows_rsSearch=0)
 echo Sorry no products were found;
 else


 // All seems OK to here, then the syntax error unexpected 
 T_VARIABLE

 appears


 echo h3Please click on a product for further information./h3

 ?php do { ?
  div class=productitemimg src=products?php echo
 $row_rsSearch['product_image']; ? /
div class=text
  h3?php echo $row_rsSearch['product_name']; ?/h3
p class=style1?php echo 
$row_rsSearch['product_subtitle'];
 ?/p
a href=products?php echo 
 $row_rsSearch['product_url'];

 ?View Product/a
  div class=clear/div
  /div div class=clear/div
   center
  /center
/div
  ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?

 --
 - Gary Maddock-Greene
 Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
 news:1229875150.4229.9.ca...@localhost.localdomain...

  On Sun, 2008-12-21 at 15:40 +, Gary Maddock-Greene wrote:

 Thanks Ashley ... I have been trying that but I think my syntax 
 id

 shot!!

 ?php
  if ($totalRows_rsSearch=0)
 echo Sorry no products were found;
  else
 echo h3Please click on a product for further 
 information./h3

 ?
  !-- Product block start search results --
  ?php do { ?
  div class=productitemimg src=products?php echo
 $row_rsSearch['product_image']; ? /
div class=text
  h3?php echo $row_rsSearch['product_name']; ?/h3
p class=style1?php echo
 $row_rsSearch['product_subtitle'];
 ?/p
a href=products?php echo 
$row_rsSearch['product_url'];
 ?View Product/a
  div class=clear/div
 

Re: [PHP] eof bof in php

2008-12-21 Thread Gary Maddock-Greene
thanks for the advice re html and php mashup!! I will research to find the 
way to do it outside the php.


- Gary Maddock-Greene

Anthony Gentile asgent...@gmail.com wrote in message 
news:2ce4207d0812211021g215d5346wb0afcedf039ef...@mail.gmail.com...

?php
if (0 == $totalRows_rsSearch) {
echo h3Sorry no products were found/h3;
} else {
echo h3Please 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;
}

}
?

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


On Sun, Dec 21, 2008 at 1:07 PM, Gary Maddock-Greene 
g...@maddock-greene.co.uk wrote:


I've corrected those errors thanks but how do I insert this code as the
else statement?

?php do { ?
 div class=productitemimg src=products?php echo
$row_rsSearch['product_image']; ? /
   div class=text
 h3?php echo $row_rsSearch['product_name']; ?/h3
   p class=style1?php echo 
$row_rsSearch['product_subtitle'];

?/p
   a href=products?php echo $row_rsSearch['product_url'];
?View Product/a
 div class=clear/div
 /div div class=clear/div
  center
 /center
   /div
 ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?

--
- Gary Maddock-Greene
Anthony Gentile asgent...@gmail.com wrote in message
news:2ce4207d0812210959k3491690ctbc4f0dbf971ac...@mail.gmail.com...

 ...missing semicolon and some brackets.


?php
if (0 == $totalRows_rsSearch) {
echo h3Sorry no products were found/h3;
} else {
echo h3Please click on a product for further information./h3;
}
?

If there is more code you can show by perhaps pasting here:
http://pastebin.redlinktech.com
We can help with further syntax problems.

Anthony Gentile



On Sun, Dec 21, 2008 at 12:33 PM, Gary Maddock-Greene 
g...@maddock-greene.co.uk wrote:

 Thanks guys .. I can get this part working great ..


?php
if (0 == $totalRows_rsSearch) {
echo h3Sorry no products were found/h3;
} else
echo h3Please click on a product for further information./h3
?

But I want to add the following so that only the products table appears
when product are present. I cannot seem to add this code into the above
after the echo h3Please click on a product for further
information./h3. I can't get the syntax right ...

I appreciate everyones help

--
- Gary Maddock-Greene
Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
news:1229878234.4229.12.ca...@localhost.localdomain...

 On Sun, 2008-12-21 at 11:39 -0500, Anthony Gentile wrote:



 if (0 == $totalRows_rsSearch) {

echo Sorry no products were found;
} else

Anthony Gentile



On Sun, Dec 21, 2008 at 11:22 AM, Gary Maddock-Greene 
g...@maddock-greene.co.uk wrote:

 I have tried that but to no avail :)

 ?php
 if ($totalRows_rsSearch=0)
 echo Sorry no products were found;
 else


 // All seems OK to here, then the syntax error unexpected 
 T_VARIABLE

 appears


 echo h3Please click on a product for further information./h3

 ?php do { ?
  div class=productitemimg src=products?php echo
 $row_rsSearch['product_image']; ? /
div class=text
  h3?php echo $row_rsSearch['product_name']; ?/h3
p class=style1?php echo 
$row_rsSearch['product_subtitle'];
 ?/p
a href=products?php echo 
 $row_rsSearch['product_url'];

 ?View Product/a
  div class=clear/div
  /div div class=clear/div
   center
  /center
/div
  ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?

 --
 - Gary Maddock-Greene
 Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
 news:1229875150.4229.9.ca...@localhost.localdomain...

  On Sun, 2008-12-21 at 15:40 +, Gary Maddock-Greene wrote:

 Thanks Ashley ... I have been trying that but I think my syntax 
 id

 shot!!

 ?php
  if ($totalRows_rsSearch=0)
 echo Sorry no products were found;
  else
 echo h3Please click on a product for further 
 information./h3

 ?
  !-- Product block start search results --
  ?php do { ?
  div class=productitemimg src=products?php echo
 $row_rsSearch['product_image']; ? /
div class=text
  h3?php echo $row_rsSearch['product_name']; ?/h3
p class=style1?php echo
 $row_rsSearch['product_subtitle'];
 ?/p
a href=products?php echo 
$row_rsSearch['product_url'];
 ?View Product/a
  div class=clear/div
  /div div class=clear/div
   center
  /center
/div
  ?php } while ($row_rsSearch = 

[PHP] Re: Create PHP form from MySQL table structure

2008-12-21 Thread Al



R B MacGregor wrote:

Hi folks

Anybody got any recommendations for a utility which would create a quick head 
start by creating the php/html code for a basic form using the field structure 
of a MySQL table ?


Thanks for any suggestions.



Look at Pear HTML_QuickForm and other HTML classes.

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



Re: [PHP] eof bof in php

2008-12-21 Thread Gary Maddock-Greene
I guess you are right about mixing php with html. Actually the suggestion 
you gave breaks my search function. If I now search for a product called 
'type 22'  the space and first digit 2 breaks the serach. Also the \ in the 
htnl / php is causing a break in the image path urls ... so back to the 
drawing board for me :)


--
- Gary Maddock-Greene
Gary Maddock-Greene g...@maddock-greene.co.uk wrote in message 
news:b4.82.23981.dee8e...@pb1.pair.com...
thanks for the advice re html and php mashup!! I will research to find the 
way to do it outside the php.


- Gary Maddock-Greene

Anthony Gentile asgent...@gmail.com wrote in message 
news:2ce4207d0812211021g215d5346wb0afcedf039ef...@mail.gmail.com...

?php
if (0 == $totalRows_rsSearch) {
echo h3Sorry no products were found/h3;
} else {
echo h3Please 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;
}

}
?

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


On Sun, Dec 21, 2008 at 1:07 PM, Gary Maddock-Greene 
g...@maddock-greene.co.uk wrote:


I've corrected those errors thanks but how do I insert this code as the
else statement?

?php do { ?
 div class=productitemimg src=products?php echo
$row_rsSearch['product_image']; ? /
   div class=text
 h3?php echo $row_rsSearch['product_name']; ?/h3
   p class=style1?php echo 
$row_rsSearch['product_subtitle'];

?/p
   a href=products?php echo $row_rsSearch['product_url'];
?View Product/a
 div class=clear/div
 /div div class=clear/div
  center
 /center
   /div
 ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?

--
- Gary Maddock-Greene
Anthony Gentile asgent...@gmail.com wrote in message
news:2ce4207d0812210959k3491690ctbc4f0dbf971ac...@mail.gmail.com...

 ...missing semicolon and some brackets.


?php
if (0 == $totalRows_rsSearch) {
echo h3Sorry no products were found/h3;
} else {
echo h3Please click on a product for further information./h3;
}
?

If there is more code you can show by perhaps pasting here:
http://pastebin.redlinktech.com
We can help with further syntax problems.

Anthony Gentile



On Sun, Dec 21, 2008 at 12:33 PM, Gary Maddock-Greene 
g...@maddock-greene.co.uk wrote:

 Thanks guys .. I can get this part working great ..


?php
if (0 == $totalRows_rsSearch) {
echo h3Sorry no products were found/h3;
} else
echo h3Please click on a product for further information./h3
?

But I want to add the following so that only the products table 
appears
when product are present. I cannot seem to add this code into the 
above

after the echo h3Please click on a product for further
information./h3. I can't get the syntax right ...

I appreciate everyones help

--
- Gary Maddock-Greene
Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
news:1229878234.4229.12.ca...@localhost.localdomain...

 On Sun, 2008-12-21 at 11:39 -0500, Anthony Gentile wrote:



 if (0 == $totalRows_rsSearch) {

echo Sorry no products were found;
} else

Anthony Gentile



On Sun, Dec 21, 2008 at 11:22 AM, Gary Maddock-Greene 
g...@maddock-greene.co.uk wrote:

 I have tried that but to no avail :)

 ?php
 if ($totalRows_rsSearch=0)
 echo Sorry no products were found;
 else


 // All seems OK to here, then the syntax error unexpected 
 T_VARIABLE

 appears


 echo h3Please click on a product for further information./h3

 ?php do { ?
  div class=productitemimg src=products?php echo
 $row_rsSearch['product_image']; ? /
div class=text
  h3?php echo $row_rsSearch['product_name']; ?/h3
p class=style1?php echo 
$row_rsSearch['product_subtitle'];
 ?/p
a href=products?php echo 
 $row_rsSearch['product_url'];

 ?View Product/a
  div class=clear/div
  /div div class=clear/div
   center
  /center
/div
  ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?

 --
 - Gary Maddock-Greene
 Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
 news:1229875150.4229.9.ca...@localhost.localdomain...

  On Sun, 2008-12-21 at 15:40 +, Gary Maddock-Greene wrote:

 Thanks Ashley ... I have been trying that but I think my syntax 
 id

 shot!!

 ?php
  if ($totalRows_rsSearch=0)
 echo Sorry no products were found;
  else
 echo h3Please click on a product for further 
 information./h3

 ?
  !-- Product block start search results --
  ?php do { ?
  div class=productitemimg 

Re: [PHP] eof bof in php

2008-12-21 Thread Gary Maddock-Greene

I guess you are right about mixing php with html. Actually the suggestion
you gave breaks my search function. If I now search for a product called
'type 22'  the space and first digit 2 breaks the serach. Also the \ in the
htnl / php is causing a break in the image path urls ... so back to the
drawing board for me :)

--
- Gary Maddock-Greene
Gary Maddock-Greene g...@maddock-greene.co.uk wrote in message
news:b4.82.23981.dee8e...@pb1.pair.com...

thanks for the advice re html and php mashup!! I will research to find the
way to do it outside the php.

- Gary Maddock-Greene

Anthony Gentile asgent...@gmail.com wrote in message
news:2ce4207d0812211021g215d5346wb0afcedf039ef...@mail.gmail.com...

?php
if (0 == $totalRows_rsSearch) {
echo h3Sorry no products were found/h3;
} else {
echo h3Please 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;
}

}
?

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


On Sun, Dec 21, 2008 at 1:07 PM, Gary Maddock-Greene 
g...@maddock-greene.co.uk wrote:


I've corrected those errors thanks but how do I insert this code as the
else statement?

?php do { ?
 div class=productitemimg src=products?php echo
$row_rsSearch['product_image']; ? /
   div class=text
 h3?php echo $row_rsSearch['product_name']; ?/h3
   p class=style1?php echo
$row_rsSearch['product_subtitle'];
?/p
   a href=products?php echo $row_rsSearch['product_url'];
?View Product/a
 div class=clear/div
 /div div class=clear/div
  center
 /center
   /div
 ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?

--
- Gary Maddock-Greene
Anthony Gentile asgent...@gmail.com wrote in message
news:2ce4207d0812210959k3491690ctbc4f0dbf971ac...@mail.gmail.com...

 ...missing semicolon and some brackets.


?php
if (0 == $totalRows_rsSearch) {
echo h3Sorry no products were found/h3;
} else {
echo h3Please click on a product for further information./h3;
}
?

If there is more code you can show by perhaps pasting here:
http://pastebin.redlinktech.com
We can help with further syntax problems.

Anthony Gentile



On Sun, Dec 21, 2008 at 12:33 PM, Gary Maddock-Greene 
g...@maddock-greene.co.uk wrote:

 Thanks guys .. I can get this part working great ..


?php
if (0 == $totalRows_rsSearch) {
echo h3Sorry no products were found/h3;
} else
echo h3Please click on a product for further information./h3
?

But I want to add the following so that only the products table
appears
when product are present. I cannot seem to add this code into the
above
after the echo h3Please click on a product for further
information./h3. I can't get the syntax right ...

I appreciate everyones help

--
- Gary Maddock-Greene
Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
news:1229878234.4229.12.ca...@localhost.localdomain...

 On Sun, 2008-12-21 at 11:39 -0500, Anthony Gentile wrote:



 if (0 == $totalRows_rsSearch) {

echo Sorry no products were found;
} else

Anthony Gentile



On Sun, Dec 21, 2008 at 11:22 AM, Gary Maddock-Greene 
g...@maddock-greene.co.uk wrote:

 I have tried that but to no avail :)

 ?php
 if ($totalRows_rsSearch=0)
 echo Sorry no products were found;
 else


 // All seems OK to here, then the syntax error unexpected
 T_VARIABLE
 appears


 echo h3Please click on a product for further information./h3

 ?php do { ?
  div class=productitemimg src=products?php echo
 $row_rsSearch['product_image']; ? /
div class=text
  h3?php echo $row_rsSearch['product_name']; ?/h3
p class=style1?php echo 
$row_rsSearch['product_subtitle'];
 ?/p
a href=products?php echo
 $row_rsSearch['product_url'];
 ?View Product/a
  div class=clear/div
  /div div class=clear/div
   center
  /center
/div
  ?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?

 --
 - Gary Maddock-Greene
 Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
 news:1229875150.4229.9.ca...@localhost.localdomain...

  On Sun, 2008-12-21 at 15:40 +, Gary Maddock-Greene wrote:

 Thanks Ashley ... I have been trying that but I think my syntax
 id
 shot!!

 ?php
  if ($totalRows_rsSearch=0)
 echo Sorry no products were found;
  else
 echo h3Please click on a product for further
 information./h3
 ?
  !-- Product block start search results --
  ?php do { ?
  div class=productitemimg src=products?php echo
 

[PHP] Variable as an index

2008-12-21 Thread MikeP
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 



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



Re: [PHP] Variable as an index

2008-12-21 Thread Marc Steinert

MikeP schrieb:

I have tried putting the quotes all over and all I get is:
'Array[U]'.

  

Try to avoid accessing the two-dimensional array $users inside a string.
Use echo's ability to accept multiple parameters:

echo 'trtd.', $users[$x]['U'], '/td';

Or by concating the string with the .-Operator:

echo 'trtd.'.$users[$x]['U'].'/td';

The first method is faster and needs less memory.

--
http://bithub.net/
Synchronize and share your files over the web for free


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



Re: [PHP] Variable as an index

2008-12-21 Thread German Geek
$users is an array and you are trying to simply put it in a string. $x seems
to be undefined ergo it's not printing anything. If 'U' is the index in the
array for your variable, use the '.' operator to concatenate strings:

echo tr
   td width='110' bgcolor='$row_color' nowrap
  ' . $users[$x]['U'] .'/td
   /tr;

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Mon, Dec 22, 2008 at 10:44 AM, MikeP mpel...@princeton.edu wrote:

 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



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




Re: [PHP] Variable as an index

2008-12-21 Thread German Geek
OK. I would think it uses more memory then, but doubt it would be slower.
Isnt the output buffered in memory anyway though in PHP? Surely the buffer
is bigger than 100 bytes (which is about the length of this string). So one
way or the other, the memory is used.

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Mon, Dec 22, 2008 at 11:12 AM, Marc Steinert li...@bithub.net wrote:

 German Geek schrieb:

 Why is the first method faster and uses less memory?



 Because the concatenation operator first reassembles a new string, stores
 it in memory then passes this newly created string to the echo function, if
 I'm not misstaken.


 --
 http://bithub.net/
 Synchronize and share your files over the web for free




Re: [PHP] Variable as an index

2008-12-21 Thread German Geek
Why is the first method faster and uses less memory?

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Mon, Dec 22, 2008 at 10:59 AM, Marc Steinert li...@bithub.net wrote:

 MikeP schrieb:

 I have tried putting the quotes all over and all I get is:
 'Array[U]'.



 Try to avoid accessing the two-dimensional array $users inside a string.
 Use echo's ability to accept multiple parameters:

 echo 'trtd.', $users[$x]['U'], '/td';

 Or by concating the string with the .-Operator:

 echo 'trtd.'.$users[$x]['U'].'/td';

 The first method is faster and needs less memory.

 --
 http://bithub.net/
 Synchronize and share your files over the web for free



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




Re: [PHP] Variable as an index

2008-12-21 Thread Marc Steinert

German Geek schrieb:

Why is the first method faster and uses less memory?

  
Because the concatenation operator first reassembles a new string, 
stores it in memory then passes this newly created string to the echo 
function, if I'm not misstaken.


--
http://bithub.net/
Synchronize and share your files over the web for free


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



Re: [PHP] Variable as an index

2008-12-21 Thread Anthony Gentile
for e.g.
$var = 'world';
echo hello $var;
vs
echo 'hello '.$var;

The first uses twice as many opcodes as compared to the second. The first is
init a string and adding to it the first part(string) and then the second
part (var); once completed it can echo it out. The second is simply two
opcodes, a concatenate and an echo. Interpolation.

Anthony Gentile


On Sun, Dec 21, 2008 at 5:47 PM, German Geek geek...@gmail.com wrote:

 OK. I would think it uses more memory then, but doubt it would be slower.
 Isnt the output buffered in memory anyway though in PHP? Surely the buffer
 is bigger than 100 bytes (which is about the length of this string). So one
 way or the other, the memory is used.

 Tim-Hinnerk Heuer

 http://www.ihostnz.com


 On Mon, Dec 22, 2008 at 11:12 AM, Marc Steinert li...@bithub.net wrote:

  German Geek schrieb:
 
  Why is the first method faster and uses less memory?
 
 
 
  Because the concatenation operator first reassembles a new string, stores
  it in memory then passes this newly created string to the echo function,
 if
  I'm not misstaken.
 
 
  --
  http://bithub.net/
  Synchronize and share your files over the web for free
 
 



Re: [PHP] Replacing special characters with their HTML equivalents

2008-12-21 Thread Daniel Brown
On Sun, Dec 21, 2008 at 18:30, James Colannino ja...@colannino.org 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.)

Welcome to the list, James.

Check out htmlentities(): http://php.net/htmlentities

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: [PHP] Variable as an index

2008-12-21 Thread Anthony Gentile
True, it might mean the very slightest in milliseconds...depending on what
you're doing/hardware. However, no harm in understanding the difference/how
it works.
Many will code echo Hello World and echo 'Hello World'; and never know the
difference, I just happen to think being aware of the details will help for
the long term programmer.
Since, I brought it up, I'll go ahead and give another example. Ternaries
that make a lot of people feel awesome because a lot is being accomplished
in one line are also more opcodes than their if-else statement
equivalents...and often times can be more confusing to future maintainers of
the code.

Anthony Gentile



On Sun, Dec 21, 2008 at 6:20 PM, Chris dmag...@gmail.com wrote:

 Anthony Gentile wrote:

 for e.g.
 $var = 'world';
 echo hello $var;
 vs
 echo 'hello '.$var;

 The first uses twice as many opcodes as compared to the second. The first
 is
 init a string and adding to it the first part(string) and then the second
 part (var); once completed it can echo it out. The second is simply two
 opcodes, a concatenate and an echo. Interpolation.


 I'd call this a micro-optimization. If changing this causes that much of a
 difference in your script, wow - you're way ahead of the rest of us.


 http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html

 http://www.phpbench.com/

 --
 Postgresql  php tutorials
 http://www.designmagick.com/




[PHP] Replacing special characters with their HTML equivalents

2008-12-21 Thread James Colannino
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.  Not all special characters
cause the problem; vowels with macrons work, for example.

I don't know if it's failing during the actual query or if the character
is being filtered out at some earlier stage, but whatever the cause,
it's not working.

My question is, is there a way to replace these characters with their
HTML equivalents?  For example, the a with an umlot over the top is
#xE4; in HTML, so before the query is made, and before the filtering on
the string is done, I'd like to replace that special character with its
HTML representation.  This allows the user to see the character while
it's in its text box, yet at the same time allow it to be successfully
imported into the database.

I know about str_replace, but assuming it's the right function for the
job, how would I go about representing these special characters in PHP
so that it will understand what I'm trying to do?

Thanks!

James
-- 
Black holes are where God divided by zero. --Steven Wright



signature.asc
Description: OpenPGP digital signature


Re: [PHP] Variable as an index

2008-12-21 Thread Chris

Anthony Gentile wrote:
True, it might mean the very slightest in milliseconds...depending on 
what you're doing/hardware.


Connecting to a db will (probably) take longer than most of those 
differences, let alone running a query  processing the results.


Ternaries that make a lot of people feel awesome because a lot is being 
accomplished in one line are also more opcodes than their if-else 
statement equivalents...and often times can be more confusing to future 
maintainers of the code.


I dislike ternaries for their over-use - I've seen nested ternaries and 
it's taken me 10 mins to read the code.. *shudder*.


--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP] Replacing special characters with their HTML equivalents

2008-12-21 Thread James Colannino
Daniel Brown wrote:

 Welcome to the list, James.

Thanks :)

 Check out htmlentities(): http://php.net/htmlentities

I'll check that out.

James
-- 
Black holes are where God divided by zero. --Steven Wright



signature.asc
Description: OpenPGP digital signature


Re: [PHP] Variable as an index

2008-12-21 Thread Chris

Anthony Gentile wrote:

for e.g.
$var = 'world';
echo hello $var;
vs
echo 'hello '.$var;

The first uses twice as many opcodes as compared to the second. The first is
init a string and adding to it the first part(string) and then the second
part (var); once completed it can echo it out. The second is simply two
opcodes, a concatenate and an echo. Interpolation.


I'd call this a micro-optimization. If changing this causes that much of 
a difference in your script, wow - you're way ahead of the rest of us.


http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html

http://www.phpbench.com/

--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP] Variable as an index

2008-12-21 Thread German Geek
Yes, i agree with this. Even if it takes a few nano seconds more to write
out more understandable code, it's worth doing it because code management is
more important than sqeezing out the last nano second. And then also an
$var = Hello;
echo $val World;

has less characters than and is more readable than

$var = Hello;
echo $var . World;

So it would take maybe a few nano seconds less to read it from the hard
drive. And we all know that disk I/O is more expensive than pushing around
variables in main memory in terms of time. And RAM is soo cheap these days.

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Mon, Dec 22, 2008 at 12:50 PM, Anthony Gentile asgent...@gmail.comwrote:

 True, it might mean the very slightest in milliseconds...depending on what
 you're doing/hardware. However, no harm in understanding the difference/how
 it works.
 Many will code echo Hello World and echo 'Hello World'; and never know
 the
 difference, I just happen to think being aware of the details will help for
 the long term programmer.
 Since, I brought it up, I'll go ahead and give another example. Ternaries
 that make a lot of people feel awesome because a lot is being accomplished
 in one line are also more opcodes than their if-else statement
 equivalents...and often times can be more confusing to future maintainers
 of
 the code.

 Anthony Gentile



 On Sun, Dec 21, 2008 at 6:20 PM, Chris dmag...@gmail.com wrote:

  Anthony Gentile wrote:
 
  for e.g.
  $var = 'world';
  echo hello $var;
  vs
  echo 'hello '.$var;
 
  The first uses twice as many opcodes as compared to the second. The
 first
  is
  init a string and adding to it the first part(string) and then the
 second
  part (var); once completed it can echo it out. The second is simply two
  opcodes, a concatenate and an echo. Interpolation.
 
 
  I'd call this a micro-optimization. If changing this causes that much of
 a
  difference in your script, wow - you're way ahead of the rest of us.
 
 
 
 http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html
 
  http://www.phpbench.com/
 
  --
  Postgresql  php tutorials
  http://www.designmagick.com/
 
 



Re: [PHP] Replacing special characters with their HTML equivalents

2008-12-21 Thread Larry Garfield
On Sunday 21 December 2008 5:30:25 pm 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.  Not all special characters
 cause the problem; vowels with macrons work, for example.

 I don't know if it's failing during the actual query or if the character
 is being filtered out at some earlier stage, but whatever the cause,
 it's not working.

 My question is, is there a way to replace these characters with their
 HTML equivalents?  For example, the a with an umlot over the top is
 #xE4; in HTML, so before the query is made, and before the filtering on
 the string is done, I'd like to replace that special character with its
 HTML representation.  This allows the user to see the character while
 it's in its text box, yet at the same time allow it to be successfully
 imported into the database.

 I know about str_replace, but assuming it's the right function for the
 job, how would I go about representing these special characters in PHP
 so that it will understand what I'm trying to do?

 Thanks!

 James

You may find this useful:

http://www.garfieldtech.com/blog/unicode-8-vs-16

-- 
Larry Garfield
la...@garfieldtech.com

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



Re: [PHP] Variable as an index

2008-12-21 Thread Lars Torben Wilson
2008/12/21 German Geek geek...@gmail.com:
 Yes, i agree with this. Even if it takes a few nano seconds more to write
 out more understandable code, it's worth doing it because code management is
 more important than sqeezing out the last nano second. And then also an
 $var = Hello;
 echo $val World;

 has less characters than and is more readable than

 $var = Hello;
 echo $var . World;

 So it would take maybe a few nano seconds less to read it from the hard
 drive. And we all know that disk I/O is more expensive than pushing around
 variables in main memory in terms of time. And RAM is soo cheap these days.

 Tim-Hinnerk Heuer

 http://www.ihostnz.com

Agreed. Although I tend to use ' instead of  unless I need
interpolation, if I feel it's really going to make that much of a
difference then I start looking at rewriting that section in C or
refactoring. String interpolation shouldn't be a bottleneck.

Getting back to the original question though, the correct way to
express a multidimensional array access inside a string is to use
curly braces, and include quotes around any string index names:

echo An array: {$arr[$foo]['bar']}\n;


Torben

 On Mon, Dec 22, 2008 at 12:50 PM, Anthony Gentile asgent...@gmail.comwrote:

 True, it might mean the very slightest in milliseconds...depending on what
 you're doing/hardware. However, no harm in understanding the difference/how
 it works.
 Many will code echo Hello World and echo 'Hello World'; and never know
 the
 difference, I just happen to think being aware of the details will help for
 the long term programmer.
 Since, I brought it up, I'll go ahead and give another example. Ternaries
 that make a lot of people feel awesome because a lot is being accomplished
 in one line are also more opcodes than their if-else statement
 equivalents...and often times can be more confusing to future maintainers
 of
 the code.

 Anthony Gentile



 On Sun, Dec 21, 2008 at 6:20 PM, Chris dmag...@gmail.com wrote:

  Anthony Gentile wrote:
 
  for e.g.
  $var = 'world';
  echo hello $var;
  vs
  echo 'hello '.$var;
 
  The first uses twice as many opcodes as compared to the second. The
 first
  is
  init a string and adding to it the first part(string) and then the
 second
  part (var); once completed it can echo it out. The second is simply two
  opcodes, a concatenate and an echo. Interpolation.
 
 
  I'd call this a micro-optimization. If changing this causes that much of
 a
  difference in your script, wow - you're way ahead of the rest of us.
 
 
 
 http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html
 
  http://www.phpbench.com/
 
  --
  Postgresql  php tutorials
  http://www.designmagick.com/
 
 





-- 
Torben Wilson tor...@2powerweb.com

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