patheticsam Posted May 13, 2010 Share Posted May 13, 2010 Hi! I'm havving a little issue with a simple search script with SELECT command. I just changed hoster to go with Godaddy and it seems that the select does not work anymore...(it was working perfectly on previous server). Here's a little bit of my code : here's the search form (pretty simple) : <form enctype="multipart/form-data" action="search_result.php" method="POST" target="main"> <td style="text-align: left;" colspan="2"><input type="text" name="search" style="width: 300px;"><input type="submit" value="Rechercher"></td> </form> And here's the result part : <?php mysql_connect("localhost", "user", "pass") or die(mysql_error()); mysql_select_db("db") or die(mysql_error()); $data = mysql_query("SELECT * FROM `opportunite` WHERE `entreprise` LIKE '%$search%' ORDER by `categorie`") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { echo " <table border=\"0\" celppadding=\"0\" cellspacing=\"0\" style=\"font-weight: bold; width: 850px;\"> <tr onmouseover=\"mover(this);\" onmouseout=\"mout(this);\"> <td style=\"width: 200px;\">".$info['entreprise']."</td> <td style=\"width: 150px;\">".$info['vendeur']."</td> <td style=\"width: 200px;\">".$info['categorie']."</td> <td style=\"width: 150px;\"><a href=\"view_client.php?cmd=view&id=".$info['id']."\">Visionner / Modifier</a></td> <td style=\"width: 150px;\"><a href=\"delete_client.php?cmd=delete&id=".$info['id']."\">Supprimer</a></td> </tr> </table> "; } ?> The problem is when I make a search I always get all the results in db instead of the specific word im looking for....It was working perfectly on the previous server....???? Any help is appreciated! Thanks Quote Link to comment Share on other sites More sharing options...
patheticsam Posted May 13, 2010 Author Share Posted May 13, 2010 Is it possible that it's due to PHP version 5? Quote Link to comment Share on other sites More sharing options...
Psycho Posted May 13, 2010 Share Posted May 13, 2010 I would assume that $search is not getting defined - which I think would result in all the recrods getting pulled. Have you validated the query getting generated? I always create the queries as a string variable so I can echo to the page for debugging purposes. Try this: $query = "SELECT * FROM `opportunite` WHERE `entreprise` LIKE '%$search%' ORDER by `categorie`"; echo "Query: $query"; $data = mysql_query($query) or die(mysql_error()); Is it possible that it's due to PHP version 5? Think about it. A PHP update causing a MySQL query to return different results? Not possible. Quote Link to comment Share on other sites More sharing options...
Psycho Posted May 13, 2010 Share Posted May 13, 2010 [Delete] Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted May 13, 2010 Share Posted May 13, 2010 Remove enctype="multipart/form-data" from the <form> tag and see if that helps. Ken Quote Link to comment Share on other sites More sharing options...
patheticsam Posted May 13, 2010 Author Share Posted May 13, 2010 found the problem! thanks! Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted May 13, 2010 Share Posted May 13, 2010 What was the problem? Quote Link to comment 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.