Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1406 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Mysql error (mysql_fetch_array doesn't work?)

Thread title: Mysql error (mysql_fetch_array doesn't work?)
     
    Thread tools Search this thread Display Modes  
Prev Previous Post   Next Post Next
09-30-2009, 07:44 PM
#1
.Cyanide is offline .Cyanide
Status: Senior Member
Join date: Mar 2006
Location: Stockholm,Sweden
Expertise: Web Design, Coding
Software: Phoshop CS3
 
Posts: 757
iTrader: 4 / 100%
 

.Cyanide is an unknown quantity at this point

Send a message via MSN to .Cyanide

  Old  Mysql error (mysql_fetch_array doesn't work?)

Hey

I have this problem with me php code, I have no idea what the problem is, so I was hoping you guys could help me out.

Here's the code
PHP Code:
<html>
<head>
<title>Lab 4</title>
</head>
<body>
<?
$connection 
mysql_connect("xxx""xxx""xxx") or die ("Kunde inte an****a!");

mysql_select_db("xxx"$connection);

$input $_POST['revealThis'];

if (
$input == debattartiklar
    
$sql "SELECT * FROM debatt";
else if(
$input == eva)
    
$sql "SELECT * FROM debatt, sports WHERE forfattare='Eva Svensson'";
else
    echo 
"Du valde inget alternativ, vänligen välj ett";
    
    
$result mysql_query($sql$connection);

while (
$myRow mysql_fetch_array($result)) {
        echo 
"<h3 style=\"lineheight:1.5em;margin:0;padding:0;\">" $myRow['rubrik'] . "</h3>";
        echo 
"<strong>" $myRow['ingress'] . "</strong><br />";
        echo 
$myRow['brodtext'] . "<br />";
        echo 
$myRow['forfattare'] . ", " $myRow['datum'] . "<br /><br />";
}

mysql_close($connection);

?>
</body>
</html>
And this is the error i get:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in D:\FTPROOT\KTD\sh09hf1763\www\webbapplikationer09\ lab4\lab.php on line 23

Here's the script in action if you want to have a look at it. The input-radio-option that does not work is the second one, the first works perfectly.

http://student.ktd.sh.se/~sh09hf1763...lab4/form.html

Thanks alot!

EDIT: I realized you can't fetch something from a table where the fetch-item does not exist. However, I now have no idea how I'm going to make it possible to search all tables for posts by the author "Eva Svensson"

Reply With Quote
     


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed