curt22 Posted December 21, 2006 Share Posted December 21, 2006 whats wrong with this code?[quote]<?phpif ($_post[field] == chapter) {include 'connect.php';$sql = "SELECT * FROM bible WHERE MATCH($_POST[field]) AGAINST('$_POST[find]' IN BOOLEAN MODE) LIMIT 0, 30 ";$result = mysql_query($sql) or die(mysql_error());while($row = mysql_fetch_array($result)){ echo "\r\n$row[testimate] $row[book] $row[chapter]:$row[verse] <br>$row[versetext]</br>"; elseif }elseif ($_post[field] == book) {include 'connect.php';$sql = "SELECT * FROM bible WHERE MATCH($_POST[field]) AGAINST('$_POST[find]' IN BOOLEAN MODE) LIMIT 0, 30 ";$result = mysql_query($sql) or die(mysql_error());while($row = mysql_fetch_array($result)) echo "\r\n$row[testimate] $row[book] $row[chapter]:$row[verse] <br>$row[versetext]</br>"; }elseif ($_post[field] == testimate){include 'connect.php';$sql = "SELECT * FROM bible WHERE MATCH($_POST[field]) AGAINST('$_POST[find]' IN BOOLEAN MODE) LIMIT 0, 30 ";$result = mysql_query($sql) or die(mysql_error());}else {include 'connect.php';$result = mysql_query("select * from bibleWhere $_post[field] like '%$_post[find]%'") or die(mysql_error()); while($row = mysql_fetch_array($result)) echo "\r\n$row[testimate] $row[book] $row[chapter]:$row[verse] <br>$row[versetext]</br>";}?>[/quote] ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? Quote Link to comment https://forums.phpfreaks.com/topic/31542-solved-help-with-php-and-mysql/ Share on other sites More sharing options...
chronister Posted December 22, 2006 Share Posted December 22, 2006 What errors are you getting? A little more information would be very helpful.From the Posting Guidelines:[url=http://www.phpfreaks.com/forums/index.php/topic,6264.0.html]http://www.phpfreaks.com/forums/index.php/topic,6264.0.html[/url][quote]4. Ask good questions! Consider the wording of your question carefully, [b]be specific about your problem(s),[/b] and make sure that you have actually asked a question. Use punctuation and spelling to the best of your ability. Run on paragraphs without sentence breaks, and full of mispelled words limits your chances for a reply.[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/31542-solved-help-with-php-and-mysql/#findComment-146163 Share on other sites More sharing options...
curt22 Posted December 22, 2006 Author Share Posted December 22, 2006 Nothing it just shows a blank page. ??? Quote Link to comment https://forums.phpfreaks.com/topic/31542-solved-help-with-php-and-mysql/#findComment-146166 Share on other sites More sharing options...
btherl Posted December 22, 2006 Share Posted December 22, 2006 1. You should put quotes around all string constants, like this:[code=php:0]if ($_post['field'] == 'chapter') {[/code]2. You should include connect.php only once.3. You have a lone "elseif" in the first while loop. Removing that should fix the "blank page". Blank page usually means there's a problem with your syntax. Quote Link to comment https://forums.phpfreaks.com/topic/31542-solved-help-with-php-and-mysql/#findComment-146215 Share on other sites More sharing options...
chronister Posted December 22, 2006 Share Posted December 22, 2006 I agree with btherl...The empty elseif on line 11 is probably the most likely culprit of a blank page. But if that's the case, then your error reporting is not set right (for development anyway). If its a server where you have no control over the php.ini file, I suggest using this line at the top of your pages while developing them [code]<?php ini_set('error_reporting', E_ALL); ?>[/code]This will turn error reporting for things like this. My system outputs the following error for the problem on line 11.Parse error: parse error, unexpected T_ELSEIF in C:\Program Files\xampp\htdocs\nate.localnet\testing.php on line 11 Quote Link to comment https://forums.phpfreaks.com/topic/31542-solved-help-with-php-and-mysql/#findComment-146232 Share on other sites More sharing options...
curt22 Posted December 23, 2006 Author Share Posted December 23, 2006 I changed the code to this[quote]<?phpini_set('error_reporting', E_ALL);include 'connect.php';if ($_post['field'] == 'chapter') {$sql = "SELECT * FROM bible WHERE MATCH($_POST['field']) AGAINST('$_POST['find']' IN BOOLEAN MODE) LIMIT 0, 30 ";$result = mysql_query($sql) or die(mysql_error());while($row = mysql_fetch_array($result)){ echo "\r\n$row['testimate'] $row['book'] $row['chapter']:$row['verse'] <br>$row['versetext']</br>"; }elseif ($_post['field'] == 'book') {$sql = "SELECT * FROM bible WHERE MATCH($_POST['field']) AGAINST('$_POST['find']' IN BOOLEAN MODE) LIMIT 0, 30 ";$result = mysql_query($sql) or die(mysql_error());while($row = mysql_fetch_array($result)) echo "\r\n$row['testimate'] $row['book'] $row['chapter']:$row['verse'] <br>$row['versetext']</br>"; }elseif ($_post['field'] == 'testimate'){$sql = "SELECT * FROM bible WHERE MATCH($_POST['field']) AGAINST('$_POST['find']' IN BOOLEAN MODE) LIMIT 0, 30 ";$result = mysql_query($sql) or die(mysql_error());}else {$result = mysql_query("select * from bibleWhere $_post[field] like '%$_post['find']%'") or die(mysql_error()); while($row = mysql_fetch_array($result)) echo "\r\n$row['testimate'] $row['book'] $row['chapter']:$row['verse'] <br>$row['versetext']</br>";}?>[/quote]but its still not working. Quote Link to comment https://forums.phpfreaks.com/topic/31542-solved-help-with-php-and-mysql/#findComment-146638 Share on other sites More sharing options...
chronister Posted December 23, 2006 Share Posted December 23, 2006 since I don't have form and database to work with, I can't really do much more right now than have you try some things, but try echoing the form variables at the top and make sure you are recieving them. then echo your sql statements to ensure they are correctly inserting the variables, and do a $num=mysql_num_rows; echo $num to make sure you are returning results. See what you find there and I will try to help more tomorrow.EDIT:the full line just in case you don't know, is $num=mysql_num_rows($result); echo $num;insert this right below each of your $result variables and ensure that its giving you results for your search. Quote Link to comment https://forums.phpfreaks.com/topic/31542-solved-help-with-php-and-mysql/#findComment-146784 Share on other sites More sharing options...
artacus Posted December 23, 2006 Share Posted December 23, 2006 When you run into a blank page, you should change the error reporting level. If that doesnt help, add code to print a message as it steps through each part of your page to see where it fails. Quote Link to comment https://forums.phpfreaks.com/topic/31542-solved-help-with-php-and-mysql/#findComment-146791 Share on other sites More sharing options...
curt22 Posted December 27, 2006 Author Share Posted December 27, 2006 Thanks for the help I changed the error reporting level and got the page to work :) but now I have another problem :( how can I make this part of the code :[quote]if ($find == 'book') {$sql = "SELECT * FROM bible WHERE MATCH($find) AGAINST('$whattofind' IN BOOLEAN MODE) LIMIT 0, 30 ";$result = mysql_query($sql) or die(mysql_error());while($row = mysql_fetch_array($result)) echo "</br>$row[testimate] $row[book] $row[chapter]:$row[verse] $row[versetext]</br>"; }[/quote]search for words with less than 4 letters. I know I could use like %$find% but I don't want to. Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/31542-solved-help-with-php-and-mysql/#findComment-148323 Share on other sites More sharing options...
fenway Posted December 27, 2006 Share Posted December 27, 2006 You'll have to recompile mysql & change the stopword length. Quote Link to comment https://forums.phpfreaks.com/topic/31542-solved-help-with-php-and-mysql/#findComment-148378 Share on other sites More sharing options...
curt22 Posted December 27, 2006 Author Share Posted December 27, 2006 Is there anything else I could do? i can't recompile mysql. Quote Link to comment https://forums.phpfreaks.com/topic/31542-solved-help-with-php-and-mysql/#findComment-148519 Share on other sites More sharing options...
fenway Posted December 28, 2006 Share Posted December 28, 2006 Not really... this is a hard-coded limitation. Quote Link to comment https://forums.phpfreaks.com/topic/31542-solved-help-with-php-and-mysql/#findComment-148604 Share on other sites More sharing options...
curt22 Posted December 28, 2006 Author Share Posted December 28, 2006 Is there any way i could check if they have any words with less than 4 letters and let them know that they will not be included ??? Quote Link to comment https://forums.phpfreaks.com/topic/31542-solved-help-with-php-and-mysql/#findComment-149023 Share on other sites More sharing options...
fenway Posted December 30, 2006 Share Posted December 30, 2006 If you want to be really fancy, you could run a LIKE %xxx% for all words that are shorter than 4... Quote Link to comment https://forums.phpfreaks.com/topic/31542-solved-help-with-php-and-mysql/#findComment-149973 Share on other sites More sharing options...
curt22 Posted December 31, 2006 Author Share Posted December 31, 2006 Sorry but I'm new to php and mysql how could I do that ??? Quote Link to comment https://forums.phpfreaks.com/topic/31542-solved-help-with-php-and-mysql/#findComment-150395 Share on other sites More sharing options...
fenway Posted December 31, 2006 Share Posted December 31, 2006 Well, simply look at $find, determine it's length, and run whatever query will work. Quote Link to comment https://forums.phpfreaks.com/topic/31542-solved-help-with-php-and-mysql/#findComment-150444 Share on other sites More sharing options...
curt22 Posted January 1, 2007 Author Share Posted January 1, 2007 I tried using the explode function then counting the letters and and if any words have less than 4 letters it lets them know it won't be included, and I got it working but now it shows there search results twice.It looks like this:[quote]You searched for: VERSETEXT TEST.In the field: versetext.Your search returned 1 matches.old genesis 1:1 versetextNote: the word TEST will not be included because it has less than 5 letters try using a differant word or click below to try to use a Like search.and a button to use like search is here Your search returned 2 matches.old genesis 1:1 versetext[/quote]This is the code:[quote]<?php//linksinclude 'links.html';//connectinclude 'connect.php';//remove ""$find2 = $_REQUEST['field'];$find1 = htmlentities($find2);$find = mysql_real_escape_string($find1);$whattofind2 = $_REQUEST['find'];$whattofind1 = htmlentities($whattofind2);$whattofind = mysql_real_escape_string($whattofind1);$whattofind = preg_replace ( "/\s\s+/" , " " , $whattofind );// $a is used to count results results$a = 0;//make capitals$whattofind = strtoupper($whattofind);//remind them what they searched forprint '<br>';print "You searched for: $whattofind.";print '<br>';print "In the field: $find.";print '</br>'; //if they searched for a verse's text /////////////////////////////////start the search////////////////////////////////////////////////////if ($find == 'versetext') { //check for less than 4 letters$wordchunks= explode(" ", $whattofind) ;for($i = 0; $i < count($wordchunks); $i++){$length=strlen($wordchunks[$i]); if ($length < 5){echo "<b> Note: the word $wordchunks[$i] will not be included because it has less than 5 letters try using a differant word or click below to try to use a Like search.</b><br> <form action='searchresults2.php' method='post'> <input type='hidden' size='20' maxlength='40' name='find' value='$whattofind'> <input type='submit' value='use like search' /> "; }echo '</form>';$sql = "SELECT * FROM bible WHERE MATCH(versetext) AGAINST('$whattofind' IN BOOLEAN MODE) LIMIT 0, 30 ";$result = mysql_query($sql) or die(mysql_error());while($row = mysql_fetch_array($result)){ $a++;}echo "Your search returned $a matches."; $sql = "SELECT * FROM bible WHERE MATCH(versetext) AGAINST('$whattofind' IN BOOLEAN MODE) LIMIT 0, 30 ";$result = mysql_query($sql) or die(mysql_error());while($row = mysql_fetch_array($result)){ echo "<br></br>$row[testimate] $row[book] $row[chapter]:$row[verse] <br>$row[versetext]</br>"; } } }else {//if they searched for something else$result = mysql_query("SELECT * FROM bible WHERE $find LIKE '%$whattofind%' ") or die(mysql_error()); while($row = mysql_fetch_array($result)){$a++;}echo "your search retutrned $a matches.";$result = mysql_query("SELECT * FROM bible WHERE $find LIKE '%$whattofind%' ") or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<br><br>$row[testimate] $row[book] $row[chapter]:$row[verse] </br>$row[versetext]</br>";}}mysql_free_result($result);?>[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/31542-solved-help-with-php-and-mysql/#findComment-150834 Share on other sites More sharing options...
curt22 Posted January 2, 2007 Author Share Posted January 2, 2007 Thanks for the help I got it to work. Incase anyone wants to see it this this what i changed it to:[quote]<html><head><title></title><body><?php//linksinclude 'links.html';//connectinclude 'connect.php';//remove ""$find2 = $_REQUEST['field'];$find1 = htmlentities($find2);$find = mysql_real_escape_string($find1);$whattofind2 = $_REQUEST['find'];$whattofind1 = htmlentities($whattofind2);$whattofind = mysql_real_escape_string($whattofind1);$whattofind = str_replace(",", " ", $whattofind);$whattofind = preg_replace ( "/\s\s+/" , " " , $whattofind );// $a is used to count results results$a = 0;//make capitals$whattofind = strtoupper($whattofind);//remind them what they searched forprint '<br>';print "You searched for: $whattofind.";print '<br>';print "In the field: $find.";print '</br>'; //if they searched for a verse's text /////////////////////////////////start the search////////////////////////////////////////////////////if ($find == 'versetext') { //check for less than 4 letters$wordchunks= explode(" ", $whattofind) ;for($i = 0; $i < count($wordchunks); $i++){$length=strlen($wordchunks[$i]); if ($length < 5){echo "<b> Note: the word $wordchunks[$i] will not be included because it has less than 5 letters try using a differant word or click below to try to use a Like search.</b><br> <form action='searchresults2.php' method='post'> <input type='hidden' size='20' maxlength='40' name='find' value='$whattofind'> <input type='submit' value='use like search' /> "; echo '</form>';}}$sql = "SELECT * FROM bible WHERE MATCH(versetext) AGAINST('$whattofind' IN BOOLEAN MODE) LIMIT 0, 30 ";$result = mysql_query($sql) or die(mysql_error());while($row = mysql_fetch_array($result)){ $a++;}echo "Your search returned $a matches."; $sql = "SELECT * FROM bible WHERE MATCH(versetext) AGAINST('$whattofind' IN BOOLEAN MODE) LIMIT 0, 30 ";$result = mysql_query($sql) or die(mysql_error());while($row = mysql_fetch_array($result)){ echo "<br></br>$row[testimate] $row[book] $row[chapter]:$row[verse] <br>$row[versetext]</br>"; } } else {//if they searched for something else$result = mysql_query("SELECT * FROM bible WHERE $find LIKE '%$whattofind%' ") or die(mysql_error()); while($row = mysql_fetch_array($result)){$a++;}echo "your search retutrned $a matches.";$result = mysql_query("SELECT * FROM bible WHERE $find LIKE '%$whattofind%' ") or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<br><br>$row[testimate] $row[book] $row[chapter]:$row[verse] </br>$row[versetext]</br>";}}mysql_free_result($result);?></body></html>[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/31542-solved-help-with-php-and-mysql/#findComment-151448 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.