udaystrad Posted November 19, 2013 Share Posted November 19, 2013 Got stuck with some coding.. the same sort of code is working somwhere else .....but not able to trace why this isnt workin? Here's the code... <?php $host="localhost"; // Host name $username="root"; // Mysql username $password="india123"; // Mysql password $db_name="test"; // Database name $members="members"; $mid=009; $sa="Potekar"; $sql="sdadsaasd"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $then=mysql_query("SELECT * FROM $members WHERE MID='$mid' and Surname='$sa'"); $array = mysql_fetch_array($then); $count=mysql_num_rows($array); if (!$array) { echo "$sql<br>" . mysql_error(); } else { // check if any records found if ($count==0) { echo "No matching records<br>"; } else { $ra="sid"; $sid=$array['FirstName']; echo $sid.'<br/>'; echo $ra; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/284042-not-able-to-retrieve-datapls-help/ Share on other sites More sharing options...
udaystrad Posted November 19, 2013 Author Share Posted November 19, 2013 (edited) phpMyAdmin 2.11.11.3 NO errors i think i m not able to retrieve data at selection of table.... i want it to retrieve data n display it out there has to be somethin in the array i dont kno y its not showing n giving output .... sdadsaasd even if i manage to get smethin in array... the count should cum 1.... which is 0 as it enters that loop and gives output.... no matching records both of which are wrong.... is it syntax error .... or what i m not able to trace it out....????? Edited November 19, 2013 by udaystrad Quote Link to comment https://forums.phpfreaks.com/topic/284042-not-able-to-retrieve-datapls-help/#findComment-1458933 Share on other sites More sharing options...
Barand Posted November 19, 2013 Share Posted November 19, 2013 (edited) I recommend that you read the manual for mysql_query, mysql_num_rows and mysql_fetch_array and look carefully at what parameters they require and what they return. edit: and turn error_reporting on. Edited November 19, 2013 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/284042-not-able-to-retrieve-datapls-help/#findComment-1458939 Share on other sites More sharing options...
Solution udaystrad Posted November 20, 2013 Author Solution Share Posted November 20, 2013 k. i did find the mistake. i jus had to place the value in inverted comas ie $mid='009'; as the value insterd in the table was text value. Error reporting was already ON and like i said so there were no errors from the code. thank you for the help. Quote Link to comment https://forums.phpfreaks.com/topic/284042-not-able-to-retrieve-datapls-help/#findComment-1459146 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.