QuickOldCar Posted March 20, 2011 Share Posted March 20, 2011 yeah I see the issue change this: $search = $GET_['search']; to this: $search = $_GET['search']; Quote Link to comment https://forums.phpfreaks.com/topic/231118-search-engine-code-php-i-need-help/page/2/#findComment-1189753 Share on other sites More sharing options...
GPCoin Posted March 20, 2011 Author Share Posted March 20, 2011 I can never understand php, Another error: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'seanhall_search'@'free.monkeyserve.com' (using password: YES) in /home/seanhall/public_html/search.php on line 14 Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'seanhall'@'localhost' (using password: NO) in /home/seanhall/public_html/search.php on line 16 Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/seanhall/public_html/search.php on line 16 SELECT * FROM searchengine WHERE keywords LIKE '%test%' Warning: mysql_query() [function.mysql-query]: Access denied for user 'seanhall'@'localhost' (using password: NO) in /home/seanhall/public_html/search.php on line 29 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/seanhall/public_html/search.php on line 29 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/seanhall/public_html/search.php on line 30 Quote Link to comment https://forums.phpfreaks.com/topic/231118-search-engine-code-php-i-need-help/page/2/#findComment-1189755 Share on other sites More sharing options...
QuickOldCar Posted March 20, 2011 Share Posted March 20, 2011 Well you got that far. You need to make sure you have the correct spelling and the right information to connect to your database properly. Quote Link to comment https://forums.phpfreaks.com/topic/231118-search-engine-code-php-i-need-help/page/2/#findComment-1189757 Share on other sites More sharing options...
GPCoin Posted March 20, 2011 Author Share Posted March 20, 2011 oh and also if you type age of war a page i had added in the mysql to test it, this pops up: you searched for age of war Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'seanhall_search'@'free.monkeyserve.com' (using password: YES) in /home/seanhall/public_html/search.php on line 15 Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'seanhall'@'localhost' (using password: NO) in /home/seanhall/public_html/search.php on line 17 Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/seanhall/public_html/search.php on line 17 SELECT * FROM searchengine WHERE keywords LIKE '%age%' Warning: mysql_query() [function.mysql-query]: Access denied for user 'seanhall'@'localhost' (using password: NO) in /home/seanhall/public_html/search.php on line 30 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/seanhall/public_html/search.php on line 30 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/seanhall/public_html/search.php on line 31 No results Found.SELECT * FROM searchengine WHERE SELECT * FROM searchengine WHERE keywords LIKE '%age%' OR keywords LIKE '%of%' Warning: mysql_query() [function.mysql-query]: Access denied for user 'seanhall'@'localhost' (using password: NO) in /home/seanhall/public_html/search.php on line 30 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/seanhall/public_html/search.php on line 30 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/seanhall/public_html/search.php on line 31 No results Found.SELECT * FROM searchengine WHERE SELECT * FROM searchengine WHERE SELECT * FROM searchengine WHERE keywords LIKE '%age%' OR keywords LIKE '%of%' OR keywords LIKE '%war%' Warning: mysql_query() [function.mysql-query]: Access denied for user 'seanhall'@'localhost' (using password: NO) in /home/seanhall/public_html/search.php on line 30 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/seanhall/public_html/search.php on line 30 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/seanhall/public_html/search.php on line 31 No results Found. Quote Link to comment https://forums.phpfreaks.com/topic/231118-search-engine-code-php-i-need-help/page/2/#findComment-1189759 Share on other sites More sharing options...
QuickOldCar Posted March 20, 2011 Share Posted March 20, 2011 That's because you aren't connecting to your database whatsoever. Quote Link to comment https://forums.phpfreaks.com/topic/231118-search-engine-code-php-i-need-help/page/2/#findComment-1189761 Share on other sites More sharing options...
GPCoin Posted March 20, 2011 Author Share Posted March 20, 2011 oh! ok I think I know what I have to do, if it works i'll post it. Quote Link to comment https://forums.phpfreaks.com/topic/231118-search-engine-code-php-i-need-help/page/2/#findComment-1189763 Share on other sites More sharing options...
GPCoin Posted March 20, 2011 Author Share Posted March 20, 2011 got it to connect it to mysql ussing this: $db_host = "localhost"; $db_username = "seanhall_search"; $db_pass = "*****"; $db_name = "seanhall_search"; @mysql_connect("$db_host","$db_username"."$db_pass") and i have got this error: Parse error: syntax error, unexpected T_VARIABLE in /home/seanhall/public_html/search.php on line 22 here is line 22 $search_exploded = explode(" ",$search); hopefully this is the last error Quote Link to comment https://forums.phpfreaks.com/topic/231118-search-engine-code-php-i-need-help/page/2/#findComment-1189768 Share on other sites More sharing options...
QuickOldCar Posted March 20, 2011 Share Posted March 20, 2011 forget the semicolon here? @mysql_connect("$db_host","$db_username"."$db_pass"); Quote Link to comment https://forums.phpfreaks.com/topic/231118-search-engine-code-php-i-need-help/page/2/#findComment-1189770 Share on other sites More sharing options...
GPCoin Posted March 20, 2011 Author Share Posted March 20, 2011 lines 22-36: $search_exploded = explode(" ",$search); foreach($search_exploded as $search_each) { $x++; if ($x==1) { $construct .= "keywords LIKE '%$search_each%'"; } else { $construct .= " OR keywords LIKE '%$search_each%'"; } $construct = "SELECT * FROM searchengine WHERE $construct"; echo $construct; $run = mysql_query($construct); $found = mysql_num_rows($run); if ($found==0) { echo "No results Found."; Quote Link to comment https://forums.phpfreaks.com/topic/231118-search-engine-code-php-i-need-help/page/2/#findComment-1189772 Share on other sites More sharing options...
GPCoin Posted March 20, 2011 Author Share Posted March 20, 2011 there is't a semicolon there? Quote Link to comment https://forums.phpfreaks.com/topic/231118-search-engine-code-php-i-need-help/page/2/#findComment-1189773 Share on other sites More sharing options...
QuickOldCar Posted March 20, 2011 Share Posted March 20, 2011 you can post your entire code but I feel it's the line before @mysql_connect("$db_host","$db_username"."$db_pass") no semicolon at the end Quote Link to comment https://forums.phpfreaks.com/topic/231118-search-engine-code-php-i-need-help/page/2/#findComment-1189775 Share on other sites More sharing options...
GPCoin Posted March 20, 2011 Author Share Posted March 20, 2011 kk Quote Link to comment https://forums.phpfreaks.com/topic/231118-search-engine-code-php-i-need-help/page/2/#findComment-1189776 Share on other sites More sharing options...
QuickOldCar Posted March 20, 2011 Share Posted March 20, 2011 gotta wrap that sucker....lol <?php $search = $_GET['search']; if (!isset($search)) { echo "Please enter a keyword!"; } else { if (strlen($search)<=2){ echo "search term to short"; } else { echo "you searched for $search <hr size='1'>"; } $db_host = "localhost"; $db_username = "seanhall_search"; $db_pass = "*****"; //i edited the password $db_name = "seanhall_search"; @mysql_connect("$db_host","$db_username"."$db_pass"); // i added a semicolon here $search_exploded = explode(" ",$search); foreach($search_exploded as $search_each) { $x++; if ($x==1) { $construct .= "keywords LIKE '%$search_each%'"; } else { $construct .= " OR keywords LIKE '%$search_each%'"; } $construct = "SELECT * FROM searchengine WHERE $construct"; echo $construct; $run = mysql_query($construct); $found = mysql_num_rows($run); if ($found==0) { echo "No results Found."; } else { echo "$foundnum results found!<p>"; while ($runrows = mysql_fetch_assoc($run)) { $title = $runrows['title']; $desc = $runrows['description']; $url = $runrows['url']; echo " <b>$title</b><br> $desc<br> <a herf='$url'>$url</a><br> "; } } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/231118-search-engine-code-php-i-need-help/page/2/#findComment-1189777 Share on other sites More sharing options...
GPCoin Posted March 20, 2011 Author Share Posted March 20, 2011 im going to call it a day and come on tommrow. Quote Link to comment https://forums.phpfreaks.com/topic/231118-search-engine-code-php-i-need-help/page/2/#findComment-1189784 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.