•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 374,194 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,550 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 221 | Replies: 2
![]() |
This maybe an old chessnut to you old sweats but I am a newbie to this.. I getting this error:-
mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\dsg\Mytest.php on line 9
the database is called Camsdb
the table is called DBF
the fields of which there are three
1) refid
2)Datfd
3)Datfd2
the database connects but if fails on line 9
This is the code:
Can someone help me as I am a real nubie to this connection lark
Regards Trevor
mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\dsg\Mytest.php on line 9
the database is called Camsdb
the table is called DBF
the fields of which there are three
1) refid
2)Datfd
3)Datfd2
the database connects but if fails on line 9
This is the code:
php Syntax (Toggle Plain Text)
<?php $con = mysql_connect("192.168.10.6","trevor","trevor"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("Camsdb", $con); $result = mysql_query("SELECT * FROM DBF"); while($row = mysql_fetch_array($result)); { echo $row['Datfd'] . " " . $row['Datfd2']; echo "<br />"; } mysql_close($con); ?>
Can someone help me as I am a real nubie to this connection lark
Regards Trevor
Last edited by peter_budo : May 1st, 2008 at 12:19 pm. Reason: Keep It Organized - please use [code] tags
You have closed the while loop.
Notice the ; on the end. Remove this and you query should run.
Regards,
Alex.
php Syntax (Toggle Plain Text)
while($row = mysql_fetch_array($result));
Notice the ; on the end. Remove this and you query should run.
Regards,
Alex.
If you find my post useful please add to my reputation!! Thanks!
ajtrichards web solutions
http://www.ajtrichards.co.uk
ajtrichards web solutions
http://www.ajtrichards.co.uk
Thanks m8 for that now running sweet :-)
I have found that when ever you get this error it is MYSQL shouting that something is wrong with one of three things
1) The name of your database is wrong
2) The syntax is wrong
3) Variable not set correctly
Thanks for all your help
I have since rewritten the code so that displays properly in a nice box arrangement
this is free to look at to get going for all those like me who were having problems getting started it save so much time when you do not have to reinvent the wheel.....
I have found that when ever you get this error it is MYSQL shouting that something is wrong with one of three things
1) The name of your database is wrong
2) The syntax is wrong
3) Variable not set correctly
Thanks for all your help
I have since rewritten the code so that displays properly in a nice box arrangement
php Syntax (Toggle Plain Text)
<?php $con = mysql_connect("connection","username","passord"); if (!$con) { die('Could not connect: ' . mysql_error()); } print "Connected to MySQL<br>"; mysql_select_db("database name", $con); $result = mysql_query("SELECT * FROM DSG ORDER BY yourfield"); echo "<table border='1'> <tr> <th>yourfield</th> <th>yourfield2</th> <th>yourfield3</th> </tr>";while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['yourfield'] . "</td>"; echo "<td>" . $row['yourfield2'] . "</td>"; echo "<td>" . $row['yourfield3'] . "</td>"; echo "</tr>"; } echo "</table>"; print "code by doctoremote<br>"; mysql_close($con); ?>
Last edited by peter_budo : May 1st, 2008 at 12:19 pm. Reason: Keep It Organized - please use [code] tags
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Similar Threads
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource (PHP)
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result (PHP)
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource (PHP)
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource (MySQL)
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource (PHP)
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource (PHP)
Other Threads in the PHP Forum
- Previous Thread: Customer Service Module
- Next Thread: Display single sql data in php


Linear Mode