[PHP] Problem with preg_replace

2001-07-21 Thread James Bogosian

Currently, I am parseing a string for href tags and adding a "target=_blank"
to them to have them open up in a new window using this:
$body = preg_replace("<[aA] [hH][rR][eE][fF]=\"(.*?)\">", 'a href="$1"
target=_blank', $row->body);

This works, to the best of my knowledge, however I was curious if I could
have the target generated based on the url, so that each url would open in
its own window.  I decided to try to use the url's md5 to be its target, and
assumed that this would work:
$body = preg_replace("<[aA] [hH][rR][eE][fF]=\"(.*?)\">", 'a href="$1"
target=' . md5($1), $row->body);

however, I am getting this as an error:
Parse error: parse error, expecting `T_VARIABLE' or `'$'' in index.php on
line 201

Can anyone see what is going wrong here?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP]MySQL error, what's wrong here..

2001-07-23 Thread James Bogosian

Try:

  $query = "SELECT songname FROM mp3 WHERE sgid = '" .$id."'";

an SQL query requires you to quote strings.

james

-Original Message-
From: Chris Cocuzzo [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 23, 2001 6:57 PM
To: [EMAIL PROTECTED]
Subject: [PHP]MySQL error, what's wrong here..




the server is telling me line 43(which starts with $mp3d) is not a valid
mysql result resource. what am i doing wrong??

chris


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP]MySQL error, what's wrong here..

2001-07-23 Thread James Bogosian

In your code, you have the lines:

--
  while($mp3d = mysql_fetch_array($result))
  {
   $mp3d = mysql_fetch_array($result);
  ?>
--

In the while control structure, you are fetching a result into $mp3d, then
inside the brackets, you fetch a second (non-existing) result into $mp3d
again.  Try it without the third line of that segment.

james

-Original Message-
From: Chris Cocuzzo [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 23, 2001 7:39 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP]MySQL error, what's wrong here..


alright, new problem, no more errors, but there's just nothing...here's the
code:


  
  
  
 

and here's what the HTML code looks like from the page when i test it out..
http://www.fplg.net/stream.php?songid=2"; class="hov1">

what's going on with that...
chris

----- Original Message -
From: James Bogosian <[EMAIL PROTECTED]>
To: Chris Cocuzzo <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, July 23, 2001 7:25 PM
Subject: RE: [PHP]MySQL error, what's wrong here..


> Try:
>
>   $query = "SELECT songname FROM mp3 WHERE sgid = '" .$id."'";
>
> an SQL query requires you to quote strings.
>
> james
>
> -Original Message-
> From: Chris Cocuzzo [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 23, 2001 6:57 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP]MySQL error, what's wrong here..
>
>
>$id = rand(1,2);
>   $query = "SELECT songname FROM mp3 WHERE sgid = " .$id;
>   $result = mysql_query($query,$connection);
>   $mp3d = mysql_fetch_array($result);
>   ?>
>
> the server is telling me line 43(which starts with $mp3d) is not a valid
> mysql result resource. what am i doing wrong??
>
> chris
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]