Webmaster Forum

Advertise Here   Sell Your Website   V7N Directory
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Reply
 
LinkBack Thread Tools Display Modes
Old 05-22-2005, 01:44 PM   #1 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
PHP search script error

This is my script:
Code:
<?php @require "includes/connect.php"; $search = $_POST['search']; $explode = explode(" ", $search); $search = "biz_name LIKE '%" . implode("%' OR biz_name LIKE '%", $explode) . "%'"; $count = count($explode); $query = array(); for ($i=0, $i < $count, $i++){ $query[$i] = mysql_query("SELECT * FROM businesses WHERE $search"); } echo "<p><strong style=\"font-size: 13px;\">Standard listings</strong></p>"; if (@mysql_num_rows($result) == 0) { echo "There are currently no listings for this category."; } while (@$row = mysql_fetch_assoc($result)) { $row['biz_description'] = str_replace("\n", "\n<br />", $row['biz_description']); echo "<p style=\"padding: 10px; border: 1px dashed #C4C4C4; width: 96%;\"><a href=\"http://".$row['biz_website']."\" onclick=\"window.open(this.href,'_blank');return false;\"><strong>".$row['biz_name']."</strong> - <em>".$row['biz_website']."</em></a><br />"; echo $row['biz_description']; echo "</p>"; } ?>
i get this error:
Quote:
Parse error: parse error, expecting `';'' in search.php on line 51
line 51 is within that script but i cannot find it. What the script does is when a user searchs for example 'Webmaster Forum' it will split it into biz_name like 'webmaster' or biz_name like 'forum'.

any help fixing this will be appreciated.
Limit is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 05-22-2005, 10:56 PM   #2 (permalink)
Inactive
 
insitedev's Avatar
 
Join Date: 12-14-04
Posts: 108
iTrader: 0 / 0%
Latest Blog:
None

insitedev is liked by somebodyinsitedev is liked by somebodyinsitedev is liked by somebodyinsitedev is liked by somebody
The issue is with your for loop. Use semi-colons instead of commas to separate the parts.
insitedev is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-23-2005, 01:06 AM   #3 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
k that fixed that but how do i display the results i tried:-
Code:
while($row = @mysql_fetch_array($query)) { echo $row['biz_name']; }
but it won't display the results from the search.
Limit is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-23-2005, 01:51 AM   #4 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
when using this:-
PHP Code:
                @require "includes/connect.php";
                    
$search $_POST['search'];
                    
$explode explode(" "$search);
                 
$search "biz_name LIKE '%" implode("%' OR biz_name LIKE '%"$explode) . "%'";
                    
$count count($explode);
                    
$query = array();
                    echo 
"<p><strong style=\"font-size: 13px;\">Search Results</strong></p>";
                    for (
$i=0$i $count$i++){
                     
$query[$i] = mysql_query("SELECT biz_name, biz_description, biz_website FROM businesses WHERE $search");
                 if (@
mysql_num_rows($query[$i]) == 0) {
                     echo 
"There are currently no listings for this category.";
                    }
                 while (@
$row mysql_fetch_assoc($query[$i])) {
                  
$row['biz_description'] = str_replace("\n""\n<br />"$row['biz_description']);
                     echo 
"<p style=\"padding: 10px; border: 1px dashed #C4C4C4; width: 96%;\"><a href=\"http://".$row['biz_website']."\" onclick=\"window.open(this.href,'_blank');return false;\"><strong>".$row['biz_name']."</strong> - <em>".$row['biz_website']."</em></a><br />";
                     echo 
$row['biz_description'];
                     echo 
"</p>";
                    }
                    } 
It returns two results when i search 'webmaster forum' one for webmaster the other for forum can i fix this. so that is still searches for both biz_name LIKE 'webmaster' OR biz_name LIKE 'forum' but only show one result.
Limit is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-24-2005, 03:09 AM   #5 (permalink)
Inactive
 
insitedev's Avatar
 
Join Date: 12-14-04
Posts: 108
iTrader: 0 / 0%
Latest Blog:
None

insitedev is liked by somebodyinsitedev is liked by somebodyinsitedev is liked by somebodyinsitedev is liked by somebody
well.. you could try a couple things.

1. use DISTINCT in the query (SELECT DISTINCT [columns] WHERE .....)
2. use a GROUP BY in the query (SELECT [columns] WHERE ..... GROUP BY [uniquecolumn])

By "uniquecolumn" I mean something that would be common only if the two results were identical (such as the id).
insitedev is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-24-2005, 06:05 AM   #6 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
sorry couldn't get on last night but i have fixed the problem. It was that one of my other scripts was interfering.
Limit is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with PHP Script Error dhudiburg Coding Forum 3 01-29-2007 03:06 AM
script error? sim Coding Forum 3 06-29-2005 06:51 PM
Image script error PaulHarris Coding Forum 5 07-03-2004 10:54 AM
Script Runtime Error Debug problem Salty10is Coding Forum 2 06-30-2004 10:55 PM
User Script error Pretend Coding Forum 11 01-18-2004 07:52 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 04:33 PM.
© Copyright 2008 V7 Inc


Search Engine Optimization by vBSEO 3.1.0 ©2007, Crawlability, Inc.