Beginner Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherBeginner Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 3rd, 2003, 12:30 AM
shattered shattered is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 13 shattered User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Help on PHP search engine

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;
}
?>

Last edited by shattered : March 3rd, 2003 at 12:24 PM.

Reply With Quote
  #2  
Old March 3rd, 2003, 02:36 AM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,424 jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 2 Days 12 h 58 m 27 sec
Reputation Power: 812
Which line is line 34?
PHP Code:
function search_form($category_id) {
global 
$root_category_id$PHP_SELF;

if (!isset(
$category_id)) $category_id $root_category_id;

/* if you use $_SERVER['PHP_SELF'] instead (HIGHLY RECOMMENDED), no need to global $PHP_SELF

all of this can be written as
*/
function search_form($category_id $root_category_id)

#####

$adb = new DBI($dbstr$cfg_dbuser$cfg_dbpasswd);

/* this looks funny unless you have a DBI class?, but then you 
start selecting multiple/different dbs -- it's confusing */ 

Reply With Quote
  #3  
Old March 3rd, 2003, 02:40 AM
shattered shattered is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 13 shattered User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi there,
Thanks for your reply.
Assuming that I'm using $adb to connect mysql with php, what should I change in my codes?
Thanks for helping this hopeless PHP beginner!

Reply With Quote
  #4  
Old March 3rd, 2003, 11:46 AM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,424 jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 2 Days 12 h 58 m 27 sec
Reputation Power: 812
You didn't answer my question. Which line is line 34?

Reply With Quote
  #5  
Old March 3rd, 2003, 12:00 PM
shattered shattered is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 13 shattered User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,
Line 34 is mysql_select_db($mysqldb,$db_connect);.
That error was fixed yesterday, because I was missing a ";" somewhere up the code.

Now that I've added the missing ";", new errors appeared.
"Warning: Failed opening 'mysql_connect.inc' for inclusion (include_path='.:/usr/share/pear') in /home/omis107/search.php on line 5"
"Fatal error: Cannot instantiate non-existent class: dbi in /home/omis107/search.php on line 31"

Reply With Quote
  #6  
Old March 3rd, 2003, 12:05 PM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,424 jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 2 Days 12 h 58 m 27 sec
Reputation Power: 812
For security reasons, the "mysql_connect.inc" file needs to end with a .php extension. Rename it either mysql_connect.inc.php or just mysql_connect.php -- and don't forget to make the appropriate change in the script itself either. As for your error on line 5, the include() error, they way you have it written that file must be in the same file as the script including it. If it is, then the problem is a parse error in the mysql_connect file itself.

As for the DBI problem -- I thought that looked strange -- you have to include() a class named DBI. Did you do that?

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > Help on PHP search engine


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT