bemax Posted September 13, 2009 Share Posted September 13, 2009 Hi, Can someone help me to find what is wrong in this. It doesn't give me things from my Database. <div id="centercontent"> <table border="0" width="100%" > <tr> <td> Montrer resultat <? if(isset($_POST['find'])) { $srch = $_POST["find"];// This is what I receive from an other page - I get it (no problem) //echo "$srch"; } // Make a MySQL Connection include( "sumba/conn.php"); // Get all the data from the "News_Nk" table $result = mysql_query("SELECT id,theme,titre,text,src FROM News_Nk WHERE titre='%$srch%'") or die(mysql_error()); $info = mysql_fetch_array( $result); while($info = mysql_fetch_array($result )) { Print "<b>Titre:</b> ".$info['titre'] . " "; Print "<b>Text:</b> ".$info['text'] . " <br>"; } ?> </td> </tr> </table> </div> Thanks in advance Bemax Link to comment https://forums.phpfreaks.com/topic/174108-selectfrom-where/ Share on other sites More sharing options...
wshell Posted September 13, 2009 Share Posted September 13, 2009 see if you have a SQL error with your database using this code after your mysql_query() call... echo mysql_error(); Link to comment https://forums.phpfreaks.com/topic/174108-selectfrom-where/#findComment-917768 Share on other sites More sharing options...
cbolson Posted September 13, 2009 Share Posted September 13, 2009 Hi, You have: WHERE titre='%$srch%'" I suspect that that should be: WHERE titre LIKE '%$srch%'" Also, this line $info = mysql_fetch_array( $result); is not needed as you have this in the while loop. Chris Link to comment https://forums.phpfreaks.com/topic/174108-selectfrom-where/#findComment-917769 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.