databse search help

They have: 34 posts

Joined: Oct 2001

hello-

i am getting this error-
::::::::::::
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /web/eww/remediation/htdocs/multi_query.php on line 34
:::::::::::
line 34 is ---> do {
print $row["apn"];
:::::::::::
i can't figure out what's going on.

thanks for your time.

<?php
 

mysql_connect
(localhost, remeed, typethis);
  
mysql_select_db (remediation);

if (
$apn == \"\")
{$apn = '%';}

if (
$streetnum == \"\")
{$streetnum = '%';}

if (
$street == \"\")
{$street = '%';}

if (
$lastname == \"\")
{$lastname = '%';}

$result = mysql_query(\"SELECT property0202.apn, property0202.streetnum,
                 property0202.street, property0202.lastname
         FROM property0202, exclude2002
         WHERE ((property0202.apn LIKE '
$apn%')
              OR (property0202.streetnum LIKE '
$streetnum%')
              OR (property0202.street LIKE '
$street%')
              OR (property0202.lastname LIKE '
$lastname%')
              OR (property0202.apn = exclude2002.apn));

if (
$row = mysql_fetch_array($result)) {

do {
  print
$row[\"apn\"];
  print (\" \");
  print
$row[\"streetnum\"];
  print (\" \");
  print
$row[\"street\"];
  print (\" \");
  print
$row[\"lastname\"];
  print (\"<p>\");
} while(
$row = mysql_fetch_array($result));

} else {print \"Sorry, no records were found!\";}


?>

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

Forgot to close the quotes around your SQL statement.

They have: 34 posts

Joined: Oct 2001

in the original code i had the " " in the right place (must have pasted wrong).

i'm still getting the error on line 34, which is the 1st line of my print statement. i can't understand why this is happening.

thanks for your time.

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

Your parenthesis are not paired either.

Because the error is on the first print statement, I know that the error was caused by the quotes.

try this:

<?php


mysql_connect
(localhost, remeed, typethis);
  
mysql_select_db (remediation);

if (
$street == \"\")
{$street = '%';}

if (
$lastname == \"\")
{$lastname = '%';}

$query = \"SELECT property0202.apn, property0202.streetnum, property0202.street, property0202.lastname\"
        .\" FROM property0202, exclude2002\"
        .\" WHERE (\"
            .\" (property0202.apn = exclude2002.apn)\";
if (
$apn != \"\") {
   
$query .= \" OR property0202.apn LIKE '$apn%')\";
}
if (
$streetnum != \"\") {
   
$query .= \" OR property0202.streetnum LIKE '$streetnum%')\";
}
if (
$street != \"\") {
   
$query .= \" OR property0202.street LIKE '$street%')\";
}
if (
$lastname != \"\") {
   
$query .= \" OR property0202.lastname LIKE '$lastname%')\";
}

$result = mysql_query($query);

if (!
$result) {
  print \"Sorry, no records were found!\";
}

while (
$row=@mysql_fetch_array($result)) {
  print
$row[\"apn\"];
  print (\" \");
  print
$row[\"streetnum\"];
  print (\" \");
  print
$row[\"street\"];
  print (\" \");
  print
$row[\"lastname\"];
  print (\"<p>\");
}
?>
Making mySQL search a field for a wildcard increases the load, just omit that field.

Mark Hensler
If there is no answer on Google, then there is no question.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.