Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2001041

Re: [PHP-DB] select substring_index From: Paul Burney (burney <email protected>)
Date: 04/11/01

on 4/11/01 7:48 PM, Mike Baerwolf at mike <email protected> wrote:

> SELECT substring_index( body, ". ", 2) FROM news;
>
> This works great from the mysql client but when I try it using php with
> this:
>
> $result = mysql_query("SELECT substring_index(body, "." ,2) FROM news"

The way you have this written, PHP is using the . for concatenation. To fix
the problem you need to alternate or escape the quotes, i.e. :

$result = mysql_query("SELECT substring_index(body, \".\" ,2) FROM news"

or

$result = mysql_query('SELECT substring_index(body, "." ,2) FROM news'

or

$result = mysql_query("SELECT substring_index(body, '.' ,2) FROM news"

Hope that helps,

Paul Burney
http://paulburney.com/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>