|
|||||||
New to SitePoint Forums? Register here for free!
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: Jan 2006
Location: UK (SWANSEA)
Posts: 655
|
mysql error msg
im getting this msg when im trying to display a list of items in my database any ideas why?
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/safeasfc/public_html/work/client/admin/index.php on line 220 Code:
<p>Select the product range you want to edit<br>
<input type=radio name=table value=clarice checked=checked> Clarice Cliff<br />
<input type=radio name=table value=welsh> Welsh Gaudy<br />
<input type=radio name=table value=deco> Deco Antique<br />
<input type=radio name=table value=royal> Royal Doulton<br />
<input type=Submit name="submit" value=Edit>
<?php
if ($_POST['submit']) {
include ("dbconnect.php");
$sql="SELECT * FROM" . $_POST['table'];
$result=mysql_query($sql);
?>
<table width=293 border=1>
<tr>
<td width=171>Product Name</td>
<td width=106>Update</td>
</tr>
<tr>
<?php
while($rows=mysql_fetch_array($result)){ <-------------line 220
?>
<td><?php echo $rows['name']; ?></td>
<td align="center"><a href="update.php?id=<? echo $rows['id']; ?>">update</a></td>
</tr>
<?php
}
?>
</table>
<?php
mysql_close();
}
}
|
|
|
|
|
|
#2 |
|
dooby dooby doo
![]() ![]() ![]() Join Date: Aug 2004
Location: Manchester UK
Posts: 11,239
|
It means your query failed to return any results probably because of an error.
Change your query line to: PHP Code:
Also sanitise your post data before using it in your query. PHP Code:
|
|
|
|
|
|
#3 |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: Jan 2006
Location: UK (SWANSEA)
Posts: 655
|
arr getting this error now m8 any ideas?
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROMdeco' at line 1 deco being the table name?? |
|
|
|
|
|
#4 |
|
SitePoint Member
Join Date: Feb 2006
Posts: 19
|
your query is returning false.
var_dump the $sql variable and paste the printed output in your phpmyadmin and see the explanation of the error. |
|
|
|
|
|
#5 |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: Jan 2006
Location: UK (SWANSEA)
Posts: 655
|
what you mean var_dump sorry ??
im a little confussed because its thinking the table name is FROMdeco not just deco? |
|
|
|
|
|
#6 |
|
is_empty(2);
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Mar 2006
Posts: 1,000
|
Online man is pretty clever: http://www.php.net/var_dump
|
|
|
|
|
|
#7 |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: Jan 2006
Location: UK (SWANSEA)
Posts: 655
|
ok now im more confussed why do i need to var dump?
|
|
|
|
|
|
#8 |
|
dooby dooby doo
![]() ![]() ![]() Join Date: Aug 2004
Location: Manchester UK
Posts: 11,239
|
lol, you don't need to var_dump!
you just need to add a space between the from and the variable! PHP Code:
Spike |
|
|
|
|
|
#9 |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: Jan 2006
Location: UK (SWANSEA)
Posts: 655
|
il try that spike thank
|
|
|
|
|
|
#10 |
|
Non-Member
![]() ![]() ![]() Join Date: May 2006
Posts: 218
|
try to print the query by echo on ur browser . for ex : select * from usermaster . after successfull output copy this query in mysql and try to run it. what will be the output ?
|
|
|
|
|
|
#11 |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: Jan 2006
Location: UK (SWANSEA)
Posts: 655
|
that worked a treat m8 thank lol so silly of me!
|
|
|
|
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 16:20.












Hybrid Mode
