php-general Digest 23 Sep 2009 15:35:10 -0000 Issue 6354

Topics (messages 298268 through 298288):

Re: How to take output from an include, and embed it into a variable?
        298268 by: Puiu Hrenciuc
        298269 by: Mert Oztekin
        298283 by: Jim Lucas
        298286 by: Ashley Sheridan

NULLS vs Empty result in PHP
        298270 by: Dan Shirah
        298271 by: Samrat Kar
        298272 by: Ralph Deffke
        298273 by: Dan Shirah
        298274 by: Robert Cummings
        298275 by: Mert Oztekin
        298276 by: Ashley Sheridan
        298279 by: Dan Shirah
        298284 by: Jim Lucas
        298285 by: Dan Shirah
        298288 by: Philip Thompson

Re: Dom PDF Problem
        298277 by: Chris Wilson

Parse error: syntax error, unexpected '>'
        298278 by: Haig Davis
        298280 by: Fernando Castillo Aparicio
        298281 by: Ashley Sheridan
        298282 by: Fernando Castillo Aparicio

Re: Extract links from strings
        298287 by: Philip Thompson

Administrivia:

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

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

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


----------------------------------------------------------------------
--- Begin Message ---
Hi,

The simplest way (actually the single way I know :) ) would be to
capture the output using output buffering functions, something like this:

// start output buffering
ob_start();

// include the file that generates the HTML (or whatever content)
include "....";

// get output buffer content
$output=ob_get_contents();

// clean output buffer and stop buffering
ob_end_clean();

// the content generated in the included file is now in $output variable
// use it as you consider fit
.........


Regards,
Puiu


Rob Gould wrote:
I have an invoice table that is drawn on a number of pages, so I have all the logic in an include-file like this:

include "invoicetable_bottom.php";


However, now I'm needing to take the output from that include file and pass it as an email. To do that, I need to somehow take the output from this include file and get it into a variable somehow. Is there a simple way to do this?

Something like:  $emailtcontent = include "invoicetable_bottom.php"?

--- End Message ---
--- Begin Message ---
Output buffering will do it.

Also I am not sure but did you try retrieving content with fopen() ?

Something like

$file = 'invoicetable_bottom.php';
fopen("http://yoursite.com/folder/$file","r";);

http://tr.php.net/function.fopen

worth trying. Easier than output buffering

-----Original Message-----
From: Puiu Hrenciuc [mailto:[email protected]]
Sent: Wednesday, September 23, 2009 1:36 PM
To: [email protected]
Subject: [PHP] Re: How to take output from an include, and embed it into a 
variable?

Hi,

The simplest way (actually the single way I know :) ) would be to
capture the output using output buffering functions, something like this:

// start output buffering
ob_start();

// include the file that generates the HTML (or whatever content)
include "....";

// get output buffer content
$output=ob_get_contents();

// clean output buffer and stop buffering
ob_end_clean();

// the content generated in the included file is now in $output variable
// use it as you consider fit
.........


Regards,
Puiu


Rob Gould wrote:
> I have an invoice table that is drawn on a number of pages, so I have
> all the logic in an include-file like this:
>
> include "invoicetable_bottom.php";
>
>
> However, now I'm needing to take the output from that include file and
> pass it as an email.  To do that, I need to somehow take the output from
> this include file and get it into a variable somehow.  Is there a simple
> way to do this?
>
> Something like:  $emailtcontent = include "invoicetable_bottom.php"?

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



  ________________________________
Bu mesaj ve ekleri, mesajda g?nderildi?i belirtilen ki?i/ki?ilere ?zeldir ve 
gizlidir. Size yanl??l?kla ula?m??sa l?tfen g?nderen kisiyi bilgilendiriniz ve 
mesaj? sisteminizden siliniz. Mesaj ve eklerinin i?eri?i ile ilgili olarak 
?irketimizin herhangi bir hukuki sorumlulu?u bulunmamaktad?r. ?irketimiz 
mesaj?n ve bilgilerinin size de?i?ikli?e u?rayarak veya ge? ula?mas?ndan, 
b?t?nl???n?n ve gizlili?inin korunamamas?ndan, vir?s i?ermesinden ve bilgisayar 
sisteminize verebilece?i herhangi bir zarardan sorumlu tutulamaz.

This message and attachments are confidential and intended for the 
individual(s) stated in this message. If you received this message in error, 
please immediately notify the sender and delete it from your system. Our 
company has no legal responsibility for the contents of the message and its 
attachments. Our company shall have no liability for any changes or late 
receiving, loss of integrity and confidentiality, viruses and any damages 
caused in anyway to your computer system.

--- End Message ---
--- Begin Message ---
Mert Oztekin wrote:
> Output buffering will do it.
> 
> Also I am not sure but did you try retrieving content with fopen() ?
> 
> Something like
> 
> $file = 'invoicetable_bottom.php';
> fopen("http://yoursite.com/folder/$file","r";);
> 
> http://tr.php.net/function.fopen
> 
> worth trying. Easier than output buffering
> 

This would not work.  fopen would open the file for read.  What you would be
reading is the actual source of the document.  Not the data the script would
output when ran.

The ob_* functions are the only way that I know of to do what you are asking

> -----Original Message-----
> From: Puiu Hrenciuc [mailto:[email protected]]
> Sent: Wednesday, September 23, 2009 1:36 PM
> To: [email protected]
> Subject: [PHP] Re: How to take output from an include, and embed it into a 
> variable?
> 
> Hi,
> 
> The simplest way (actually the single way I know :) ) would be to
> capture the output using output buffering functions, something like this:
> 
> // start output buffering
> ob_start();
> 
> // include the file that generates the HTML (or whatever content)
> include "....";
> 
> // get output buffer content
> $output=ob_get_contents();
> 
> // clean output buffer and stop buffering
> ob_end_clean();
> 
> // the content generated in the included file is now in $output variable
> // use it as you consider fit
> .........
> 
> 
> Regards,
> Puiu
> 
> 
> Rob Gould wrote:
>> I have an invoice table that is drawn on a number of pages, so I have
>> all the logic in an include-file like this:
>>
>> include "invoicetable_bottom.php";
>>
>>
>> However, now I'm needing to take the output from that include file and
>> pass it as an email.  To do that, I need to somehow take the output from
>> this include file and get it into a variable somehow.  Is there a simple
>> way to do this?
>>
>> Something like:  $emailtcontent = include "invoicetable_bottom.php"?
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



--- End Message ---
--- Begin Message ---
On Wed, 2009-09-23 at 07:36 -0700, Jim Lucas wrote:
> Mert Oztekin wrote:
> > Output buffering will do it.
> > 
> > Also I am not sure but did you try retrieving content with fopen() ?
> > 
> > Something like
> > 
> > $file = 'invoicetable_bottom.php';
> > fopen("http://yoursite.com/folder/$file","r";);
> > 
> > http://tr.php.net/function.fopen
> > 
> > worth trying. Easier than output buffering
> > 
> 
> This would not work.  fopen would open the file for read.  What you would be
> reading is the actual source of the document.  Not the data the script would
> output when ran.
> 
> The ob_* functions are the only way that I know of to do what you are asking
> 
> > -----Original Message-----
> > From: Puiu Hrenciuc [mailto:[email protected]]
> > Sent: Wednesday, September 23, 2009 1:36 PM
> > To: [email protected]
> > Subject: [PHP] Re: How to take output from an include, and embed it into a 
> > variable?
> > 
> > Hi,
> > 
> > The simplest way (actually the single way I know :) ) would be to
> > capture the output using output buffering functions, something like this:
> > 
> > // start output buffering
> > ob_start();
> > 
> > // include the file that generates the HTML (or whatever content)
> > include "....";
> > 
> > // get output buffer content
> > $output=ob_get_contents();
> > 
> > // clean output buffer and stop buffering
> > ob_end_clean();
> > 
> > // the content generated in the included file is now in $output variable
> > // use it as you consider fit
> > .........
> > 
> > 
> > Regards,
> > Puiu
> > 
> > 
> > Rob Gould wrote:
> >> I have an invoice table that is drawn on a number of pages, so I have
> >> all the logic in an include-file like this:
> >>
> >> include "invoicetable_bottom.php";
> >>
> >>
> >> However, now I'm needing to take the output from that include file and
> >> pass it as an email.  To do that, I need to somehow take the output from
> >> this include file and get it into a variable somehow.  Is there a simple
> >> way to do this?
> >>
> >> Something like:  $emailtcontent = include "invoicetable_bottom.php"?
> > 
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

That's just crazy talk. If you use fopen on a web URL, then it will
always return the output the script generates. That's how http works!

Thanks,
Ash
http://www.ashleysheridan.co.uk




--- End Message ---
--- Begin Message ---
Morning!

Just a quick question.

Say I have a column in my database that could contain NULLS, empty spaces,
or an actual value.

If I do:

$my_query = "SELECT my_column FROM my_database WHERE 1 = 1";
$my_result = ifx_query($my_query, $connect_id);

while($row = ifx_fetch_row($my_result)) {
  $my_column = trim($row['my_column']);

  if ($my_column != "") {
   echo "Test";
  }
}

The way PHP assigns the query results to the $my_column variable, wouldn't;
if ($my_column != "")  not do anything for the rows that contained NULLS or
empty spaces?

--- End Message ---
--- Begin Message ---
Use var_dump before processing your result.

Regards,

Samrat Kar
FRD, BARC

Tel: 022-25597295
Alternate Email: [email protected]


-----Original Message-----
From: Dan Shirah [mailto:[email protected]] 
Sent: Wednesday, September 23, 2009 5:28 PM
To: PHP General
Subject: [PHP] NULLS vs Empty result in PHP

Morning!

Just a quick question.

Say I have a column in my database that could contain NULLS, empty spaces,
or an actual value.

If I do:

$my_query = "SELECT my_column FROM my_database WHERE 1 = 1";
$my_result = ifx_query($my_query, $connect_id);

while($row = ifx_fetch_row($my_result)) {
  $my_column = trim($row['my_column']);

  if ($my_column != "") {
   echo "Test";
  }
}

The way PHP assigns the query results to the $my_column variable, wouldn't;
if ($my_column != "")  not do anything for the rows that contained NULLS or
empty spaces?

No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.409 / Virus Database: 270.13.112/2388 - Release Date: 09/22/09
17:54:00



--- End Message ---
--- Begin Message ---
using empty() is ´the right way to check a var for NULL or ""

however, it also depends what MySQL has got as setuo definition for empty
fields. on textfields u can define an epmty string as default.

[email protected]

"Dan Shirah" <[email protected]> wrote in message
news:[email protected]...
> Morning!
>
> Just a quick question.
>
> Say I have a column in my database that could contain NULLS, empty spaces,
> or an actual value.
>
> If I do:
>
> $my_query = "SELECT my_column FROM my_database WHERE 1 = 1";
> $my_result = ifx_query($my_query, $connect_id);
>
> while($row = ifx_fetch_row($my_result)) {
>   $my_column = trim($row['my_column']);
>
>   if ($my_column != "") {
>    echo "Test";
>   }
> }
>
> The way PHP assigns the query results to the $my_column variable,
wouldn't;
> if ($my_column != "")  not do anything for the rows that contained NULLS
or
> empty spaces?
>



--- End Message ---
--- Begin Message ---
>
> using empty() is ´the right way to check a var for NULL or ""
>
> however, it also depends what MySQL has got as setuo definition for empty
> fields. on textfields u can define an epmty string as default.
>
> So say these are the first three results of my query:

"some text" //The column actually has data
"              " //The column contains a series of spaces
"NULL"       //The column contains a NULL value

As long as I trim() the result, if (!empty()) would skip any results where
the column contains "              " OR "NULL", correct?

--- End Message ---
--- Begin Message ---
Ralph Deffke wrote:
using empty() is ´the right way to check a var for NULL or ""

Empty will also match a string containing 0. And, to me, that doesn't at all seem empty :)

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--- End Message ---
--- Begin Message ---
if it can take only numeric values u can use is_numeric()

also i suggest that you not to use nulls in dbs. instead, use "not null" and 
"default value" property. Its more simple and more effective for both managing 
your database and coding your program.


-----Original Message-----
From: Robert Cummings [mailto:[email protected]]
Sent: Wednesday, September 23, 2009 4:28 PM
To: Ralph Deffke
Cc: [email protected]
Subject: Re: [PHP] Re: NULLS vs Empty result in PHP

Ralph Deffke wrote:
> using empty() is ´the right way to check a var for NULL or ""

Empty will also match a string containing 0. And, to me, that doesn't at
all seem empty :)

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



  ________________________________
Bu mesaj ve ekleri, mesajda gönderildiği belirtilen kişi/kişilere özeldir ve 
gizlidir. Size yanlışlıkla ulaşmışsa lütfen gönderen kisiyi bilgilendiriniz ve 
mesajı sisteminizden siliniz. Mesaj ve eklerinin içeriği ile ilgili olarak 
şirketimizin herhangi bir hukuki sorumluluğu bulunmamaktadır. Şirketimiz 
mesajın ve bilgilerinin size değişikliğe uğrayarak veya geç ulaşmasından, 
bütünlüğünün ve gizliliğinin korunamamasından, virüs içermesinden ve bilgisayar 
sisteminize verebileceği herhangi bir zarardan sorumlu tutulamaz.

This message and attachments are confidential and intended for the 
individual(s) stated in this message. If you received this message in error, 
please immediately notify the sender and delete it from your system. Our 
company has no legal responsibility for the contents of the message and its 
attachments. Our company shall have no liability for any changes or late 
receiving, loss of integrity and confidentiality, viruses and any damages 
caused in anyway to your computer system.

--- End Message ---
--- Begin Message ---
On Wed, 2009-09-23 at 16:34 +0300, Mert Oztekin wrote:
> if it can take only numeric values u can use is_numeric()
> 
> also i suggest that you not to use nulls in dbs. instead, use "not null" and 
> "default value" property. Its more simple and more effective for both 
> managing your database and coding your program.
> 
> 
> -----Original Message-----
> From: Robert Cummings [mailto:[email protected]]
> Sent: Wednesday, September 23, 2009 4:28 PM
> To: Ralph Deffke
> Cc: [email protected]
> Subject: Re: [PHP] Re: NULLS vs Empty result in PHP
> 
> Ralph Deffke wrote:
> > using empty() is ´the right way to check a var for NULL or ""
> 
> Empty will also match a string containing 0. And, to me, that doesn't at
> all seem empty :)
> 
> Cheers,
> Rob.
> --
> http://www.interjinn.com
> Application and Templating Framework for PHP
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 
>   ________________________________
> Bu mesaj ve ekleri, mesajda gönderildiği belirtilen kişi/kişilere özeldir ve 
> gizlidir. Size yanlışlıkla ulaşmışsa lütfen gönderen kisiyi bilgilendiriniz 
> ve mesajı sisteminizden siliniz. Mesaj ve eklerinin içeriği ile ilgili olarak 
> şirketimizin herhangi bir hukuki sorumluluğu bulunmamaktadır. Şirketimiz 
> mesajın ve bilgilerinin size değişikliğe uğrayarak veya geç ulaşmasından, 
> bütünlüğünün ve gizliliğinin korunamamasından, virüs içermesinden ve 
> bilgisayar sisteminize verebileceği herhangi bir zarardan sorumlu tutulamaz.
> 
> This message and attachments are confidential and intended for the 
> individual(s) stated in this message. If you received this message in error, 
> please immediately notify the sender and delete it from your system. Our 
> company has no legal responsibility for the contents of the message and its 
> attachments. Our company shall have no liability for any changes or late 
> receiving, loss of integrity and confidentiality, viruses and any damages 
> caused in anyway to your computer system.

Or you could leave the database with the nulls in, and cast the value
explicitly as an integer with intval() or floatval() which will always
give you a numeric value.

Thanks,
Ash
http://www.ashleysheridan.co.uk




--- End Message ---
--- Begin Message ---
>
> if it can take only numeric values u can use is_numeric()
>
> also i suggest that you not to use nulls in dbs. instead, use "not null"
> and "default value" property. Its more simple and more effective for both
> managing your database and coding your program.
>
>

It's a CHAR (60) field.

This database has been around for close to a decade and I'm not the DBA for
it.  And with several billion records and 1000's of tables I don't see them
getting updated/changed. (The gov't doesn't like change)

--- End Message ---
--- Begin Message ---
Dan Shirah wrote:
> Morning!
> 
> Just a quick question.
> 
> Say I have a column in my database that could contain NULLS, empty spaces,
> or an actual value.
> 
> If I do:
> 
> $my_query = "SELECT my_column FROM my_database WHERE 1 = 1";
> $my_result = ifx_query($my_query, $connect_id);
> 
> while($row = ifx_fetch_row($my_result)) {
>   $my_column = trim($row['my_column']);
> 
>   if ($my_column != "") {
>    echo "Test";
>   }
> }
> 
> The way PHP assigns the query results to the $my_column variable, wouldn't;
> if ($my_column != "")  not do anything for the rows that contained NULLS or
> empty spaces?
> 

>From reading the other responses to this thread, it seems that you want to
"skip" or "exclude" rows in the results where my_column === null.

If this is correct, why not do it in the SELECT statement to begin with?

$my_query = "SELECT my_column FROM my_database WHERE my_column IS NOT NULL";

That should do it.


--- End Message ---
--- Begin Message ---
>
>  From reading the other responses to this thread, it seems that you want
> to
> "skip" or "exclude" rows in the results where my_column === null.
>
> If this is correct, why not do it in the SELECT statement to begin with?
>
> $my_query = "SELECT my_column FROM my_database WHERE my_column IS NOT
> NULL";
>
> That should do it.
>

I want to exclude the rows that might be NULL, "" (empty), or "        "
(empty series of spaces)

>From all of the input so far, it seems that using trim() on the variable and
then use empty() is the best way to pick all three types up.

--- End Message ---
--- Begin Message ---
On Sep 23, 2009, at 9:48 AM, Dan Shirah wrote:


From reading the other responses to this thread, it seems that you want
to
"skip" or "exclude" rows in the results where my_column === null.

If this is correct, why not do it in the SELECT statement to begin with?

$my_query = "SELECT my_column FROM my_database WHERE my_column IS NOT
NULL";

That should do it.


I want to exclude the rows that might be NULL, "" (empty), or " "
(empty series of spaces)

From all of the input so far, it seems that using trim() on the variable and
then use empty() is the best way to pick all three types up.

I don't think you're using mysql, but your selected db may have a similar option. I would do the work in the sql.

<?php
$sql = "SELECT * FROM `table` WHERE TRIM(`column`) <> '' AND `column` IS NOT NULL";
$result = query($sql);
while ($row = fetch_row ($result)) {
    echo "Not empty, multiple spaces or NULL!";
}
?>

So, if you have any extraneous spaces, they will be removed. It also accounts for nulls. No work is required by PHP to determine the values you need. Just use what it returns. This should work.

Hope this helps.
~Philip


--- End Message ---
--- Begin Message ---
This  might help some people struggling with memory leak problems in
DOMPDF. I haven't fixed it but it seems to have reduced the memory leak
considerably.

I have done 2 things:

1.
Added a detruct function to the DOMPDF file in dompdf.cls.php where I
unset everything. I call this each time in my loop when I'm using DOMPDF
mulitple times:

function __destruct()
{
  unset($this->_messages);
  unset($this->_xml);
  unset($this->_tree);
  unset($this->_css);
  unset($this->_pdf);
  unset($this->_paper_size);
  unset($this->_paper_orientation);
  unset($this->_base_host);
  unset($this->_base_path);
  unset($this->_cache_id);
}

2.
I now added within the render function of DOMPDF a call to the function
dispose to clean up anything left from before:

// This is where the magic happens:
$root->reflow();
        
// Memory leak fix
$root->dispose(true);

// Clean up cached images
Image_Cache::clear();


Also worth mentioning that I increased my memory allocation in my
php.ini to about 256MB, and the max execution time to about 120 seconds.

As mentioned this won't fix the problem but it does reduce the memory
used.


Chris
No virus found in this outgoing message.
Checked by AVG - www.avg.com 
Version: 8.5.416 / Virus Database: 270.13.112/2388 - Release Date:
09/23/09 05:52:00
No virus found in this outgoing message.
Checked by AVG - www.avg.com
Version: 8.5.416 / Virus Database: 270.13.112/2390 - Release Date: 09/23/09 
05:52:00

--- End Message ---
--- Begin Message ---
Good morning Everyone,

I'm have trouble with a simple HTML Checkbox list. I keep getting *Parse
error*: syntax error, unexpected '>'. I'm sure I'm doing something really
simple and basic wrong I just cannot seem to see what it is, any assistance
is appreciated.

Script:

<form method="post" action="http://bw.org/misc/cgi-test/test.cgi";>

<?php
$sql = "SELECT * FROM melstatus WHERE custID=$custID ORDER BY
aircraftRegistration";

        $q = mysql_query($q)
        or die ("could not execute query.");

    echo " <fieldset>
            <ul style='list-style: none'>\n;

    while($row = mysql_fetch_array($q))
        {
        echo " <li>".$row['melID']."<input type="checkbox"
name="\".$row['melID].\""/input> ";

        </li>\n";
        }
    echo "</ul></fieldset>

?>
</form>

Many Thanks

Haig

--- End Message ---
--- Begin Message ---
You missed a double quote here:

    echo " <fieldset>
            <ul style='list-style: none'>\n";




________________________________
De: Haig Davis <[email protected]>
Para: [email protected]
Enviado: miércoles, 23 de septiembre, 2009 16:18:17
Asunto: [PHP] Parse error: syntax error, unexpected '>'

Good morning Everyone,

I'm have trouble with a simple HTML Checkbox list. I keep getting *Parse
error*: syntax error, unexpected '>'. I'm sure I'm doing something really
simple and basic wrong I just cannot seem to see what it is, any assistance
is appreciated.

Script:

<form method="post" action="http://bw.org/misc/cgi-test/test.cgi";>

<?php
$sql = "SELECT * FROM melstatus WHERE custID=$custID ORDER BY
aircraftRegistration";

        $q = mysql_query($q)
        or die ("could not execute query.");

    echo " <fieldset>
            <ul style='list-style: none'>\n;

    while($row = mysql_fetch_array($q))
        {
        echo " <li>".$row['melID']."<input type="checkbox"
name="\".$row['melID].\""/input> ";

        </li>\n";
        }
    echo "</ul></fieldset>

?>
</form>

Many Thanks

Haig



      

--- End Message ---
--- Begin Message ---
On Wed, 2009-09-23 at 07:18 -0700, Haig Davis wrote:
> echo " <li>".$row['melID']."<input type="checkbox"
> name="\".$row['melID].\""/input> ";

You're escaping in the wrong places. The \ escapes the character
following it, so what you are doing here, in line 2, is breaking out of
the string with a regular " and then printing a " (escaped \") Also, I
think you need to brush up on your HTML a bit, as 

<input type="checkbox" name="name"/input>

is not valid HTML.


Thanks,
Ash
http://www.ashleysheridan.co.uk




--- End Message ---
--- Begin Message ---
Reading again, it's not just one miss. You have to close some strings, escape 
some quotes, etc

I think this can be right:

$sql = "SELECT * FROM melstatus WHERE custID=$custID ORDER BY
aircraftRegistration";

        $q = mysql_query($q)
        or die ("could not execute query.");

    echo " <fieldset>
            <ul style='list-style: none'>\n";

    while($row = mysql_fetch_array($q))
        {
        echo " <li>".$row['melID']."<input type=\"checkbox\"
name=\"".$row['melID']."\"/> ";

        echo "</li>\n";
        }
    echo "</ul></fieldset>";


I'd recomend you to get a good text editor with sintax highlighting if you 
haven't one. It would warn you from most of these mistakes.

And an xhtml issue: to use an empty tag, you use <tag/> and not <tag/tag>





________________________________
De: Fernando Castillo Aparicio <[email protected]>
Para: Haig Davis <[email protected]>; [email protected]
Enviado: miércoles, 23 de septiembre, 2009 16:23:07
Asunto: Re: [PHP] Parse error: syntax error, unexpected '>'

You missed a double quote here:

    echo " <fieldset>
            <ul style='list-style: none'>\n";




________________________________
De: Haig Davis <[email protected]>
Para: [email protected]
Enviado: miércoles, 23 de septiembre, 2009 16:18:17
Asunto: [PHP] Parse error: syntax error, unexpected '>'

Good morning Everyone,

I'm have trouble with a simple HTML Checkbox list. I keep getting *Parse
error*: syntax error, unexpected '>'. I'm sure I'm doing something really
simple and basic wrong I just cannot seem to see what it is, any assistance
is appreciated.

Script:

<form method="post" action="http://bw.org/misc/cgi-test/test.cgi";>

<?php
$sql = "SELECT * FROM melstatus WHERE custID=$custID ORDER BY
aircraftRegistration";

        $q = mysql_query($q)
        or die ("could not execute query.");

    echo " <fieldset>
            <ul style='list-style: none'>\n;

    while($row = mysql_fetch_array($q))
        {
        echo " <li>".$row['melID']."<input type="checkbox"
name="\".$row['melID].\""/input> ";

        </li>\n";
        }
    echo "</ul></fieldset>

?>
</form>

Many Thanks

Haig


      

--- End Message ---
--- Begin Message ---
On Sep 21, 2009, at 6:20 PM, Jim Lucas wrote:

Jim Lucas wrote:
Jônatas Zechim wrote:
Hi there, i've the following strings:

$string1 = 'Lorem ipsum dolor http://site.com sit amet';
$string2 = 'Lorem ipsum dolor http://www.site.com/ sit amet';
$string3 = 'Lorem ipsum dolor http://www.site.net sit amet';

How can I extract the URL from these strings?
They can be [http:// + url] or [www. + url].

Zechim



Something like this should work for you.

<plaintext><?php

$urls[] = 'Lorem ipsum dolor http://site.com sit amet';
$urls[] = 'Lorem ipsum dolor https://www.site.com/ sit amet';
$urls[] = 'Lorem ipsum dolor www.site1.net sit amet';
$urls[] = 'Lorem ipsum dolor www site2.net sit amet';

foreach ( $urls AS $url ) {
        if ( preg_match('%((https?://|www\.)[^\s]+)%', $url, $m) ) {
                print_r($m);
        }
}

?>


Actually, try this.  It seems to work a little better.

<plaintext><?php

$urls[] = 'Lorem ipsum dolor http://site.com sit amet';
$urls[] = 'Lorem ipsum dolor https://www.site.com/ or http://www.site2.com/' ;
$urls[] = 'Lorem ipsum dolor www.site1.net sit amet';
$urls[] = 'Lorem ipsum dolor www site2.net sit amet';

foreach ( $urls AS $url ) {
        if ( preg_match_all(    '%(https?://[^\s]+|www\.[^\s]+)%',
                                $url,
                                $m,
                                (PREG_SET_ORDER ^ PREG_OFFSET_CAPTURE)
        ) ) {
                print_r($m);
        }
}

?>

What if the sub domain was not 'www'?

http://no-www.org/

Cheers,
~Philip


--- End Message ---

Reply via email to