Closed Thread Icon

Topic awaiting preservation: Beginner search engine php question (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12628" title="Pages that link to Topic awaiting preservation: Beginner search engine php question (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Beginner search engine php question <span class="small">(Page 1 of 1)</span>\

 
shattered
Obsessive-Compulsive (I) Inmate

From:
Insane since: Feb 2003

posted posted 03-03-2003 07:32

Hi, I'm doing a search engine using PHP for a project and I keep getting "Parse errors on line 34" . Can anyone help me fix this particular error or any other errors that you see? Thank you very much!

Below is my code.

<?php
include ("mysql_connect.inc");

print ("Please search by artiste or song name.");

function search_form($category_id) {
global $root_category_id, $PHP_SELF;

/*if the search artiste is not given, we default to the root category
ID*/
if (!isset($category_id)) $category_id = $root_category_id;
?>
<CENTER>
<FORM METHOD="POST" ACTION="<?php echo $PHP_SELF?>">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="show_list">
<INPUT TYPE="HIDDEN" NAME="search_on" VALUE="1">

/*Textbox*/
Search: <INPUT TYPE="TEXT" NAME="keywords" SIZE="20"><SELECT
NAME="search_category" SIZE="1">

<INPUT TYPE="SUBMIT" VALUE="Search">
</FORM>
</CENTER>
<?php
}

/*Connect to the database*/
$adb = new DBI($dbstr, $cfg_dbuser, $cfg_dbpasswd);
mysql_select_db("radio");

function get_fulltext_key($table,$db_connect){
global $radio;
mysql_select_db($mysqldb,$db_connect);

/* grab all keys of db.table */
$indices=mysql_query("SHOW INDEX FROM $table",$db_connect);
or die(mysql_error());
$indices_rows=mysql_num_rows($indices);

/* grab only fulltext keys */
for($nth=0;$nth<$indices_rows;$nth++){
$nth_index=mysql_result($indices,$nth,'Comment');
if($nth_index=='FULLTEXT'){
$match_a[].=mysql_result($indices,$nth,'Column_name');
}
}

/* delimit with commas, implode takes an existing array as its arguement */
$match=implode(',',$match_a);

return $match;
}
?>


[This message has been edited by shattered (edited 03-03-2003).]

AT
Bipolar (III) Inmate

From: Louisville, KY, USA
Insane since: Aug 2000

posted posted 03-03-2003 08:54

Line 30 ' mysql_select_db("radio") '
is missing ;

Also 37 is the same as 39 just without an or die statement... ?
which also doesn't have a ;

just my two cents...

<edit>
Had to make sure my pass worked
</edit>



[This message has been edited by AT (edited 03-03-2003).]

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 03-03-2003 14:11

AT: Good call - I know its one of my failings too.

shattered: And the line below that also doesn't have a semi-colon so you might as well fix that problem while you are at it. Things like not adding semi-colons is the first thing you should check (and the error usually refers to the line after the missing semi-colon - I think).

___________________
Emps

FAQs: Emperor

Skaarjj
Maniac (V) Mad Scientist

From: :morF
Insane since: May 2000

posted posted 03-03-2003 15:49

I beleive it's the line before emps, since it reads the error as occuring on the start of the line, and it counts the command after as being on the same line.

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 03-03-2003 16:03

Skaarrjj: What I meant is that the error (e.g. line 35) actually gives the number of the line after the line with the actual error.

___________________
Emps

FAQs: Emperor

shattered
Obsessive-Compulsive (I) Inmate

From:
Insane since: Feb 2003

posted posted 03-03-2003 19:19

Hi there all,
Thank you for helping me point out those mistakes. I updated my codes up there, in the original post and this is what I currently have now. But I still have these following errors:

1. a parse error on line 40 (I search all over for a missing ";" but couldn't find any, if anyone can be kind enough to spot this error for me again, I'd be really grateful)

(And for number 2 and 3 errors, assuming that I'm using $adb to connect mysql and php, what should I change in the codes?)
2. "Warning: Failed opening 'mysql_connect.inc' for inclusion (include_path='.:/usr/share/pear') in /home/omis107/search.php on line 5"

3."Fatal error: Cannot instantiate non-existent class: dbi in /home/omis107/search.php on line 31"

Thank you again!




[This message has been edited by shattered (edited 03-03-2003).]

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 03-03-2003 19:40

shattered: I might be missing some cunning tweak but why is your array empty here?:

quote:
$match_a[].=



___________________
Emps

FAQs: Emperor

shattered
Obsessive-Compulsive (I) Inmate

From:
Insane since: Feb 2003

posted posted 03-04-2003 00:26

Hi Emperor,
If I'm not wrong, and this is what I quote from a reference book.

quote:
"The square brackets indicate that we want to store the values in an array. The lack of an index value lets PHP decide where to put them."


So I'm guessing that "$match_a[].=" will let the PHP automatically assign index values to the arrays?

And also

quote:
"PHP is different from from many programming languages, where arrays are concerned, on two counts. First, we don't have to predefine the data type of the array, stating wherther it will contain numbers or text. This is consistent where PHP's policy data type on variables: you don't have to choose a data type, PHP does it for you. SEcond, you also don't have to specify how large the array is before created. "





[This message has been edited by shattered (edited 03-04-2003).]

trib
Paranoid (IV) Inmate

From: Den Haag, Netherlands
Insane since: Sep 2002

posted posted 03-04-2003 07:58

3."Fatal error: Cannot instantiate non-existent class: dbi in /home/omis107/search.php on line 31"
is probably caused by ... 2. "Warning: Failed opening 'mysql_connect.inc' for inclusion (include_path='.:/usr/share/pear') in /home/omis107/search.php on line 5" ... since it's more than likely that DBI is defined in mysql_connect.inc, and theinterpreter can't find the include file in its base path. Find out where it lives, and put the full pathname into the include statement.

quote:
guessing that "$match_a[].=" will let the PHP automatically assign index values to the arrays?

Well I'd be more inclined to guess that a CONCATENATION operator needs TWO strings to concatenate together, and even if $match_a[] = "fred" works (straight assignment) ... $match_a[1] .= "fred" would probably fail because the (implied) first operand is null (i.e to start, $match_a[] is undefined until assigned a value). Try dropping the dot ...



[This message has been edited by trib (edited 03-04-2003).]

« BackwardsOnwards »

Show Forum Drop Down Menu