List:General Discussion« Previous MessageNext Message »
From:Robert Citek Date:December 10 2002 2:27pm
Subject:Re: Select * From table where name Like 'help'; Help
View as plain text  
At 05:10 PM 12/9/2002 -0500, Beauford.2003 wrote:
>I mentioned in my previous email that I am using PHP, and I have also tried
>putting quotes around $var (many different ways) with no better results.
>REGEXP just gives a syntax error when I do this.

Below is an example of using PHP and MySQL with a REGEXP condition.  It's a
variation on an example from Chapter 4 of "Web Database Applications with
PHP & MySQL" by Hugh E. Williams and David Lane, O'Reilly, 1st Ed., 2002.

Regards,
- Robert

-----

<html>
  <head>
    <title>PHP and MySQL with Regexp</title>
  </head>

  <body>
<pre>
<?php
  $connection = mysql_connect("host","username","password");
  mysql_select_db("database_name", $connection);
  $var="[[:<:]]One[[:>:]]";
  $sql="select 'Any One' regexp \"" . $var . "\"";
  echo $sql . "\n";
  $result = mysql_query("$sql", $connection);
  while( $row = mysql_fetch_row($result)) {
    echo "|";
    for ($i=0; $i<mysql_num_fields($result); $i++)
      echo " " . $row[$i] . " |" ;
    echo "\n";
  }
  mysql_close($connection);
?>
</pre>
  </body>
<html>


Thread
Select * From table where name Like 'help'; HelpBeauford.20039 Dec
  • Re: Select * From table where name Like 'help'; HelpJocelyn Fournier9 Dec
  • Re: Select * From table where name Like 'help'; HelpRobert Citek9 Dec
    • Re: Select * From table where name Like 'help'; HelpBeauford.20039 Dec
      • Re: Select * From table where name Like 'help'; HelpBenjamin Pflugmann9 Dec
    • Re: Select * From table where name Like 'help'; HelpBeauford.20039 Dec
      • ADO Bulk InsertsMichael She10 Dec
        • RE: ADO Bulk InsertsFernando Grijalba10 Dec
          • RE: ADO Bulk InsertsMichael She10 Dec
            • RE: ADO Bulk InsertsFernando Grijalba10 Dec
              • RE: ADO Bulk InsertsMichael She10 Dec
                • RE: ADO Bulk InsertsFernando Grijalba10 Dec
                  • RE: ADO Bulk InsertsMichael She10 Dec
                    • RE: ADO Bulk InsertsPaul DuBois11 Dec
                      • RE: ADO Bulk InsertsMichael She11 Dec
                        • RE: ADO Bulk Insertsed11 Dec
                        • RE: ADO Bulk InsertsPaul DuBois11 Dec
      • Re: OT Select * From table where name Like 'help'; HelpMichael T. Babcock10 Dec
      • Re: Select * From table where name Like 'help'; HelpAndy Bakun10 Dec
      • Re: Select * From table where name Like 'help'; HelpBenjamin Pflugmann10 Dec
    • Re: Select * From table where name Like 'help'; HelpBeauford.200310 Dec
      • Re: Select * From table where name Like 'help'; HelpAndy Bakun10 Dec
      • Re: Select * From table where name Like 'help'; HelpRobert Citek10 Dec
    • Re: Select * From table where name Like 'help'; HelpBeauford.200310 Dec
  • Re: Select * From table where name Like 'help'; HelpBeauford.20039 Dec
RE: ADO Bulk InsertsAlan R Anderson11 Dec
  • RE: ADO Bulk InsertsMichael She11 Dec