php-general Digest 21 May 2008 12:49:56 -0000 Issue 5471

Topics (messages 274585 through 274596):

Re: syntax of sprintf
        274585 by: Chris

Odd error
        274586 by: The Doctor
        274596 by: Thiago Pojda

Re: Enterprise
        274587 by: Nikola Stjelja
        274593 by: Colin Guthrie

strip_tags and nl2br
        274588 by: James Colannino
        274589 by: Chris
        274591 by: James Colannino
        274592 by: Chris
        274594 by: James Colannino
        274595 by: James Colannino

Re: Help Call Javascript Methods Inside PHP
        274590 by: Nitsan Bin-Nun

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 ---
> the select query is
> 
> $selectqueryusername = sprintf("Select username from individuals where
> username='%s'", mysql_real_escape_string($username));

The syntax is fine.

$result = mysql_query($selectqueryusername);
if (!$result) {
  echo "Error! *** " . mysql_error();
}


> also for insert query if i have a numeric value i should be writting %d
> correct, i have a numeric value however before inserting that
> numeric value i am appending a character "-" to combine area code and phone
> number example 09-123 4567 so i am considering this as %s as there is a
> character. is this correct.

Yes.

The placeholders are all documented pretty well:

http://www.php.net/sprintf

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

--- End Message ---
--- Begin Message ---
A customer was woring on php5.2.6/mysql 5.1 and no problem
yet with php 5.2.5 / mysql 4.1 we get:

Warning: DOMDocument::__construct() [function.DOMDocument---construct]: 
Malloc(88) in /usr/home/vesna/html/pryvit/church_maps/data_genxml.php on line 5

Warning: DOMDocument::__construct() [function.DOMDocument---construct]: 
Malloc(88) Ok in /usr/home/vesna/html/pryvit/church_maps/data_genxml.php on 
line 5

Warning: DOMDocument::__construct() [function.DOMDocument---construct]: 
Malloc(4) in /usr/home/vesna/html/pryvit/church_maps/data_genxml.php on line 5

Warning: DOMDocument::__construct() [function.DOMDocument---construct]: 
Malloc(4) Ok in /usr/home/vesna/html/pryvit/church_maps/data_genxml.php on line 
5

Warning: DOMDocument::__construct() [function.DOMDocument---construct]: 
Malloc(6) in /usr/home/vesna/html/pryvit/church_maps/data_genxml.php on line 5

Warning: DOMDocument::__construct() [function.DOMDocument---construct]: 
Malloc(6) Ok in /usr/home/vesna/html/pryvit/church_maps/data_genxml.php on line 
5

Warning: DOMDocument::createElement() [function.DOMDocument-createElement]: 
Malloc(60) in /usr/home/vesna/html/pryvit/church_maps/data_genxml.php on line 7

Warning: DOMDocument::createElement() [function.DOMDocument-createElement]: 
Malloc(60) Ok in /usr/home/vesna/html/pryvit/church_maps/data_genxml.php on 
line 7

Warning: DOMDocument::createElement() [function.DOMDocument-createElement]: 
Malloc(8) in /usr/home/vesna/html/pryvit/church_maps/data_genxml.php on line 7

Warning: DOMDocument::createElement() [function.DOMDocument-createElement]: 
Malloc(8) Ok in /usr/home/vesna/html/pryvit/church_maps/data_genxml.php on line 
7

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 
'vesna'@'localhost' (using password: YES) in 
/usr/home/vesna/html/pryvit/church_maps/data_genxml.php on line 13
Not connected : Access denied for user 'vesna'@'localhost' (using password: YES)
Warning: Unknown: Freed(8) Ok in Unknown on line 0

Warning: Unknown: Freed(60) Ok in Unknown on line 0

Warning: Unknown: Freed(4) Ok in Unknown on line 0

Warning: Unknown: Freed(6) Ok in Unknown on line 0

Warning: Unknown: Freed(88) Ok in Unknown on line 0

Any reason for this?
-- 
Member - Liberal International  
This is [EMAIL PROTECTED]       Ici [EMAIL PROTECTED]
God, Queen and country! Beware Anti-Christ rising!  
USA petition for dissolution of your nation!

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


--- End Message ---
--- Begin Message ---
Without more data and code, all I can tell is that this line should be be
read carefully:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user
'vesna'@'localhost' (using password: YES) in
/usr/home/vesna/html/pryvit/church_maps/data_genxml.php on line 13
Not connected : Access denied for user 'vesna'@'localhost' (using password:
YES)


Atenciosamente,

www.softpartech.com.br


Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
[EMAIL PROTECTED]
ExcelĂȘncia em Softwares Financeiros


-----Mensagem original-----
De: The Doctor [mailto:[EMAIL PROTECTED] 
Enviada em: quarta-feira, 21 de maio de 2008 00:33
Para: [EMAIL PROTECTED]
Assunto: [PHP] Odd error

A customer was woring on php5.2.6/mysql 5.1 and no problem
yet with php 5.2.5 / mysql 4.1 we get:

Warning: DOMDocument::__construct() [function.DOMDocument---construct]:
Malloc(88) in /usr/home/vesna/html/pryvit/church_maps/data_genxml.php on
line 5

Warning: DOMDocument::__construct() [function.DOMDocument---construct]:
Malloc(88) Ok in /usr/home/vesna/html/pryvit/church_maps/data_genxml.php on
line 5

Warning: DOMDocument::__construct() [function.DOMDocument---construct]:
Malloc(4) in /usr/home/vesna/html/pryvit/church_maps/data_genxml.php on line
5

Warning: DOMDocument::__construct() [function.DOMDocument---construct]:
Malloc(4) Ok in /usr/home/vesna/html/pryvit/church_maps/data_genxml.php on
line 5

Warning: DOMDocument::__construct() [function.DOMDocument---construct]:
Malloc(6) in /usr/home/vesna/html/pryvit/church_maps/data_genxml.php on line
5

Warning: DOMDocument::__construct() [function.DOMDocument---construct]:
Malloc(6) Ok in /usr/home/vesna/html/pryvit/church_maps/data_genxml.php on
line 5

Warning: DOMDocument::createElement() [function.DOMDocument-createElement]:
Malloc(60) in /usr/home/vesna/html/pryvit/church_maps/data_genxml.php on
line 7

Warning: DOMDocument::createElement() [function.DOMDocument-createElement]:
Malloc(60) Ok in /usr/home/vesna/html/pryvit/church_maps/data_genxml.php on
line 7

Warning: DOMDocument::createElement() [function.DOMDocument-createElement]:
Malloc(8) in /usr/home/vesna/html/pryvit/church_maps/data_genxml.php on line
7

Warning: DOMDocument::createElement() [function.DOMDocument-createElement]:
Malloc(8) Ok in /usr/home/vesna/html/pryvit/church_maps/data_genxml.php on
line 7

Warning: mysql_connect() [function.mysql-connect]: Access denied for user
'vesna'@'localhost' (using password: YES) in
/usr/home/vesna/html/pryvit/church_maps/data_genxml.php on line 13
Not connected : Access denied for user 'vesna'@'localhost' (using password:
YES)
Warning: Unknown: Freed(8) Ok in Unknown on line 0

Warning: Unknown: Freed(60) Ok in Unknown on line 0

Warning: Unknown: Freed(4) Ok in Unknown on line 0

Warning: Unknown: Freed(6) Ok in Unknown on line 0

Warning: Unknown: Freed(88) Ok in Unknown on line 0

Any reason for this?
-- 
Member - Liberal International  
This is [EMAIL PROTECTED]       Ici [EMAIL PROTECTED]
God, Queen and country! Beware Anti-Christ rising!  
USA petition for dissolution of your nation!

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


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





--- End Message ---
--- Begin Message ---
On Tue, May 20, 2008 at 11:39 AM, Richard Heyes <[EMAIL PROTECTED]>
wrote:

> Ray Hauge wrote:
>
>> I just read an interesting article about enterprise software.  One of the
>> most common arguments against PHP tends to be "It's not enterprise ready."
>>  This article talks more about ruby, but it could be about any
>> "non-enterprise" language as well.
>>
>
Bahh, it's because people can't find the difference from php the  language,
and something else the framework.

-- 
My home page:
http://www.inet.hr/~nstjelja

My Poetry Book:
http://www.lulu.de/browse/book_view.php?fCID=222964&fBuyItem=5

My OS Projects:

http://lab.linux.hr/~nstjelja/drawit/

--- End Message ---
--- Begin Message ---
Wolf wrote:
---- Ray Hauge <[EMAIL PROTECTED]> wrote:
I just read an interesting article about enterprise software. One of the most common arguments against PHP tends to be "It's not enterprise ready." This article talks more about ruby, but it could be about any "non-enterprise" language as well.

http://lists.canonical.org/pipermail/kragen-tol/2005-April/000772.html

I recently got a new job at a hospital, and the "enterprise software" they have is no where near as high quality as it could/should be. This is my first job at a somewhat large organization (500+ employees) so I was kind of shocked at the state of their software. Typically healthcare systems are further behind in the technology adoption, but having to deal with workarounds all day long sure gets old.


Realize your "recent" article was published in 2005 (read the link) and not to 
mention that this has been brought up about 6 different times in the last 4 months...

I don't know where you read it but the OP never said the article was recent.... just that he recently got a new job....

Col


--- End Message ---
--- Begin Message ---
Hey everyone,

I have a little bit of a quandry. I need to strip HTML tags from user input, but I also need to convert \n's from the textarea elements to <br> tags so it will display properly in a browser.

nl2br() works just fine, but if I use strip_tags first, then run nl2br, nl2br won't work as expected. Instead, everything shows up on a single line.

I understand why it won't work if I place a call to nl2br inside a call to strip_tags, but strip_tags doesn't get rid of \n's, right?

I'm making my calls like this:

$string = strip_tags($_SESSION['variable']);
$string = nl2br($string);

I would expect that to work, but it doesn't :( Am I missing something? I originally placed the call to strip_tags inside the call to nl2br, but when that didn't work, I tried doing these calls separately.

Thanks!

James
--
My blog: http://www.crazydrclaw.com/
My homepage: http://james.colannino.org/

"When you do the common things in life in an uncommon way, you will command the attention of the world." --George Washington Carver
--- End Message ---
--- Begin Message ---
James Colannino wrote:
> Hey everyone,
> 
> I have a little bit of a quandry.  I need to strip HTML tags from user
> input, but I also need to convert \n's from the textarea elements to
> <br> tags so it will display properly in a browser.

RTM.

Supply the tags you want to keep when you call strip_tags.

$stripped = strip_tags($data, '<br/><br>');

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

--- End Message ---
--- Begin Message ---
Chris wrote:

RTM.

Supply the tags you want to keep when you call strip_tags.

$stripped = strip_tags($data, '<br/><br>');

I can do that, but my question had to do with strip_tags seeming to get rid of \n's, not <br> tags. This is why I was concerned. If I run strip_tags(), followed by nl2br, the <br> tags that nl2br generates should be there.

James
--
My blog: http://www.crazydrclaw.com/
My homepage: http://james.colannino.org/

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

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---
--- Begin Message ---
James Colannino wrote:
> Chris wrote:
> 
>> RTM.
>>
>> Supply the tags you want to keep when you call strip_tags.
>>
>> $stripped = strip_tags($data, '<br/><br>');
> 
> I can do that, but my question had to do with strip_tags seeming to get
> rid of \n's, not <br> tags.  This is why I was concerned.  If I run
> strip_tags(), followed by nl2br, the <br> tags that nl2br generates
> should be there.

Are you sure there are newlines before you run strip_tags? It doesn't
touch newlines because they aren't html entities.

$ cat eg.php
<?php

$string = "<b>here is a bold tag</b>\n<a
href='http://www.example.com/'>Link to example.com</a>\n\n";

echo "Strip tags only:\n";
echo strip_tags($string) . "\n";
echo str_repeat('-', 10) . "\n";
echo "Strip tags & nl2br:\n";
echo nl2br(strip_tags($string)) . "\n";
?>

$ php eg.php
Strip tags only:
here is a bold tag
Link to example.com


----------
Strip tags & nl2br:
here is a bold tag<br />
Link to example.com<br />
<br />

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

--- End Message ---
--- Begin Message ---
Chris wrote:

Are you sure there are newlines before you run strip_tags?

I would assume so, because everything from the textarea runs together in one line when displayed in the browser until filtered through nl2br(). That would suggest to me that there are indeed \n's that are being converted to <br>'s.

It doesn't touch newlines because they aren't html entities.

That is exactly why I am distressed.

James
--
My blog: http://www.crazydrclaw.com/
My homepage: http://james.colannino.org/

"When you do the common things in life in an uncommon way, you will command the attention of the world." --George Washington Carver
--- End Message ---
--- Begin Message ---
James Colannino wrote:
Chris wrote:

Are you sure there are newlines before you run strip_tags?

I would assume so, because everything from the textarea runs together in one line when displayed in the browser until filtered through nl2br(). That would suggest to me that there are indeed \n's that are being converted to <br>'s.

And about 15 minutes later, it appears I'm eating my words...

My code was fine upon injecting my data into its database. However, I run strip_tags again upon extracting the data, so of course that caused problems. I solved this by entering the data with newlines instead of tags, so only when displaying the data do I run nl2br() after running strip_tags.

Now everything works fine.  Sorry for the noise everyone.

James
--
My blog: http://www.crazydrclaw.com/
My homepage: http://james.colannino.org/

"When you do the common things in life in an uncommon way, you will command the attention of the world." --George Washington Carver
--- End Message ---
--- Begin Message ---
I was surprised it didnt came up before.
As Tedd said, try to ajax-up your javascript

On 20/05/2008, tedd <[EMAIL PROTECTED]> wrote:
>
> At 11:41 AM -0300 5/20/08, Thiago Pojda wrote:
>
>> That way you can conditionally send some JS to client, but running actual
>> JS
>> in PHP is not possible.
>>
>
> While running JS inside of PHP is at best confusing, it is possible to use
> both php and javascript  together. For example:
>
> You can use php to run javascript, right?
>
> And, you can use javascript and run php, right?
>
> So, all you need between the two is communication, right?
>
> Think of ajax.
>
> Here's an example:
>
> http://webbytedd.com/b/timed-php/
>
> It just takes a little work.
>
> Cheers,
>
> tedd
> --
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---

Reply via email to