Connecting Tech Pros Worldwide Help | Site Map

help with very simple php problem...

  #1  
Old July 17th, 2005, 03:15 PM
max
Guest
 
Posts: n/a
Hi, I've just started learning some stuff about php and have been
following a couple of tutorials. At the moment I'm stuck with this small
piece of code which gives me an error "mysql_fetch_array():supplied
argument is not a valid MySql result"

<?php
include 'config.php';
include 'opendb.php';

$query="SELECT cname, csubject, cmessage FROM contact";
$result=mysql_query($query);

while($row= mysql_fetch_array($result,MYSQL_ASSOC))
{
echo
"Name :{$row['cname']} <br>" . "Subject : {$row['csubject']} <br>" .
"Message : {$row['cmessage']} <br><br>";
}
include 'closedb.php';
?>

This should just display the content of a table..
Thanx for your help!
  #2  
Old July 17th, 2005, 03:15 PM
max
Guest
 
Posts: n/a

re: help with very simple php problem...


max probably wrote the following stuff on 16/07/2005 13.01:[color=blue]
> This should just display the content of a table..
> Thanx for your help![/color]

Nevermind it's all working now, I just messed up with the DB connections
so it was looking in the wrong place! :-D
  #3  
Old July 17th, 2005, 03:15 PM
Shelly
Guest
 
Posts: n/a

re: help with very simple php problem...



"max" <nospam@nospam.com> wrote in message
news:BO5Ce.1925$B6.51988@twister1.libero.it...[color=blue]
> Hi, I've just started learning some stuff about php and have been
> following a couple of tutorials. At the moment I'm stuck with this small
> piece of code which gives me an error "mysql_fetch_array():supplied
> argument is not a valid MySql result"
>
> <?php
> include 'config.php';
> include 'opendb.php';
>
> $query="SELECT cname, csubject, cmessage FROM contact";
> $result=mysql_query($query);
>
> while($row= mysql_fetch_array($result,MYSQL_ASSOC))
> {
> echo
> "Name :{$row['cname']} <br>" . "Subject : {$row['csubject']} <br>" .
> "Message : {$row['cmessage']} <br><br>";
> }
> include 'closedb.php';
> ?>
>
> This should just display the content of a table..
> Thanx for your help![/color]

Could you please show the contents of opendb.php?

Shelly


  #4  
Old July 17th, 2005, 03:15 PM
max
Guest
 
Posts: n/a

re: help with very simple php problem...


Shelly probably wrote the following stuff on 16/07/2005 13.26:[color=blue]
> Could you please show the contents of opendb.php?
>[/color]

yeah I realized too that the problem was in there...actually in the
config.php since the opendb.php has variables that relate with the
config file.
Now everything is ok,
Thank you!
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need help with my gallery Effix answers 13 August 11th, 2008 10:45 PM
TCL/PHP problem involving a PHP function that has to utilize a TCL proc comp.lang.tcl answers 4 March 9th, 2006 12:25 AM
very simple drop-down list... max answers 20 September 23rd, 2005 01:35 PM
Need help with Snoopy class function toby casey answers 6 July 17th, 2005 08:50 AM