AcidDriver Posted July 16, 2008 Share Posted July 16, 2008 can someone identify is there is anything wrong with this search clause. $data = mysql_query("SELECT * FROM hope WHERE upper($field) LIKE '%$find%'"); I can post the entire code if needed. Link to comment https://forums.phpfreaks.com/topic/115081-solved-search-clause-help/ Share on other sites More sharing options...
LooieENG Posted July 16, 2008 Share Posted July 16, 2008 $data = mysql_query("SELECT * FROM hope WHERE upper('$field') LIKE '%$find%'"); I think Link to comment https://forums.phpfreaks.com/topic/115081-solved-search-clause-help/#findComment-591785 Share on other sites More sharing options...
AcidDriver Posted July 16, 2008 Author Share Posted July 16, 2008 I dont see where you changed anything. What did you do? Well, you changed something, and removed those errors. THANKKKKKK YOU, i cant tell you how hard that was for me. again, thank you so very very much, you saved my project. Link to comment https://forums.phpfreaks.com/topic/115081-solved-search-clause-help/#findComment-591812 Share on other sites More sharing options...
AcidDriver Posted July 16, 2008 Author Share Posted July 16, 2008 I have one more thing... <?php //Displays once search text is run through. if ($_POST['searching'] =="yes") { echo "<h1>Your results: </h1><p>"; //If nothing is entered then return no search text. if ($_POST['find'] == "") { echo "<p>Please enter a search item in the query box</"; exit; } // Else, connect direct to the database mysql_connect("localhost", "root", "") or die(mysql_error()); //Need to setup dedicated H.O.P.E server to link to mySQL, then input user/server info. mysql_select_db("hope") or die(mysql_error()); //Search for search term once in database. $data = mysql_query("SELECT * FROM hope WHERE upper('$field') LIKE '%$find%'"); I get this notice... Notice: Undefined variable: field in H:\Documents\My Web Sites\HOPE Search Database\search.php on line 21 Notice: Undefined variable: find in H:\Documents\My Web Sites\HOPE Search Database\search.php on line 21 mike ronzetti Link to comment https://forums.phpfreaks.com/topic/115081-solved-search-clause-help/#findComment-591813 Share on other sites More sharing options...
LooieENG Posted July 16, 2008 Share Posted July 16, 2008 I added ' to upper('$field'). You always need to put variables inside ' marks for MySQL. (i.e. '$var' or '$_POST[example]') Anyway, for the second question, where are $field and $find defined? Link to comment https://forums.phpfreaks.com/topic/115081-solved-search-clause-help/#findComment-591985 Share on other sites More sharing options...
AcidDriver Posted July 16, 2008 Author Share Posted July 16, 2008 they are defined in the index.html file. <html> <head> <title>Welcome to the HOPE Database</title> <link rel="stylesheet" href="text/main.css" type="text/css" /> </head> <body> <h1>H.O.P.E Volunteer Database Search</h1> <font class="title">Please enter your database query below.</font> <form name="search" method="post" action="search.php"> Search: <input type="text" value="find" name="find" /> Category: <Select NAME="field"> <Option value="fname">First Name</option><!--Searches according to the volunteers last name --> <Option value="lname">Last Name</option><!--Searches according to the volunteers first name --> <Option value="idnum">ID Number</option><!--Searches according to the volunteers ID Number --> <option value="gradyear">Graduation Year</option> </Select><br> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search Database" class="note"/> </form> <br> <br> <a href="volunteer.htm">Input a new volunteer</a> </body> </html> herer is the search again <?php //Displays once search text is run through. if ($_POST['searching'] =="yes") { echo "<h1>Your results: </h1><p>"; //If nothing is entered then return no search text. if ($_POST['find'] == "") { echo "<p>Please enter a search item in the query box</"; exit; } // Else, connect direct to the database mysql_connect("localhost", "root", "") or die(mysql_error()); //Need to setup dedicated H.O.P.E server to link to mySQL, then input user/server info. mysql_select_db("hope") or die(mysql_error()); //Search for search term once in database. $data = mysql_query("SELECT * FROM hope WHERE upper('$field') LIKE '%$find%'"); //Display results while($result = mysql_fetch_array( $data )) { echo "<u><b>"; echo $result['fname']; echo " "; echo $result['lname']; echo "</b></u><b><br>ID Number:</b> "; echo $result['idnum']; echo "<b><br>Graduation Year:</b> "; echo $result['gradyear']; //echo "<b><br>Donor:</b> "; //echo $result['donor']; //echo "<br><b>FOH/Community Partner:</b> "; //echo $result['foh']; echo "<br><b>Organization/Firm: </b>"; echo $result['org']; //echo "<br><b>HOPE Fellow:</b> "; //echo $result['fellow']; //echo "<br><b>HOPE Senior Fellow:</b> "; //echo $result['sfellow']; //echo "<br><b>Miami Scholar: </b>"; //echo $result['scholar']; //echo "<br><b>Public Interest Loan Reduction Recipient:</b> "; //echo $result['lreduce']; echo "<br><b><br>Home Address:</b>"; echo $result['address']; echo "<br>"; echo $result['city'] .", " .$result['state'] ." " .$result['zip']; echo "<br><b><br>Work Address:</b> <br>"; echo $result['waddress']; echo "<br>"; echo $result['wcity'] .", " .$result['wstate'] ." " .$result['wzip']; echo "<br><b>Work Phone:</b>"; echo $result['wphone']; echo "<br><b>Fax number: </b>"; echo $result['fax']; echo "<br><b>Cell Phone: </b>"; echo $result['cphone']; echo "<br><b>Email:</b>"; echo $result['email']; //echo "<br><b><br>Interests:</b> "; //echo $result['Interests']; //echo "<br><b>Project Leader: </b>"; //echo $result['project']; //echo "<br><b>HOPE Liason:</b> "; //echo $result['liason']; //echo "<br><b>Center for Ethics and Public Service Liason:</b> "; //echo $result['pliason']; echo "<br><br><b>Community Service Hours:</b>"; echo $result['comtotalhours']; echo "<br><dd><b>Project Name/Agency: </b></dd>"; echo $result['comagency']; echo "<br><dd><b>Date of Project: </dd></b>"; echo $result['comdate']; echo "<br><dd><b>Community Service Project Hours: </b></dd>"; echo $result['comhours']; echo "<br><br><b>Advocacy Service Hours: </b>"; echo $result['adtotalhours']; echo "<br><dd><b>Project Name/Agency: </b></dd>"; echo $result['adagency']; echo "<br><dd><b>Date of Project: </dd></b>"; echo $result['addate']; echo "<br><dd><b>Hours Volunteered: </b></dd>"; echo $result['adhours']; echo "<br><dd><b>Supervising Attorney: </b></dd>"; echo $result['adattorney']; echo "<br><dd><b>Attorney Contact: </b></dd>"; echo $result['adattorneycon']; //echo "<br><b><br>Languages: </b>"; //echo $result['languages']; echo "<br><br><br><br><br>"; } //This counts the number or results - and if there wasn't any it gives them a little message explaining that $matchnum=mysql_num_rows($data); if ($matchnum == 0) { echo "There were no results for you mySQL query.<br><br>"; } //Echo back what the user searched for: echo "<b>Searched For: </b> " .$find; echo "<b>Number of Results: </b> " .$matchnum; echo "<br>"; echo '<a href="http://127.0.0.1/HOPE%20Database/index.htm">Search Again</a>'; } ?> Link to comment https://forums.phpfreaks.com/topic/115081-solved-search-clause-help/#findComment-592002 Share on other sites More sharing options...
LooieENG Posted July 16, 2008 Share Posted July 16, 2008 You have to define $find and $field like this $find = $_POST['find'] Link to comment https://forums.phpfreaks.com/topic/115081-solved-search-clause-help/#findComment-592018 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.