/    Sign up×
Community /Pin to ProfileBookmark

mysql_fetch_array(): supplied argument is not a valid MySQL result resource

I keep getting that error message. I’m trying to get data from my database into an array to display different columns on the page

[code=php]
<?php

$link=mysql_connect(“localhost”, “username”, “password”)
or die(‘I cannot connect to the database because: ‘ . mysql_error());
mysql_select_db (“database”, $link);
$sql=”SELECT Name, Creator, Category, Socks, Steps, Difficulty, ImageType, ID
FROM Models
WHERE ID = ‘$_GET[id]’ AND Confirmed = 1″;

$result=mysql_fetch_array(mysql_query($sql, $link) or die(mysql_error()));?>

<DIV CLASS=”content”>
<DIV ID=”leftcolumn”>
Creator: <?php echo $result[‘Creator’]; ?><BR>
Difficulty: <?php echo $result[‘Difficulty’]; ?><BR>
Socks: <?php echo $result[‘Socks’]; ?><BR>
<?php echo $result[‘Steps’]; ?></DIV>
<DIV ID=”rightcolumn”><IMG SRC=”http://models.sockigami.com/images/models/<?php echo $result[‘ID’]; ?>. <?php echo $result[‘ImageType’]; ?>” ALT=”<?php echo $result[‘Model’]; ?>”></DIV></DIV>

[/code]

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@The_Little_GuySep 04.2006 — How about this:
[code=php]<?php

$link=mysql_connect("localhost", "username", "password")
or die('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("database", $link);
$sql="SELECT * FROM Models WHERE ID = '$_GET[id]' AND Confirmed = 1";
$result = mysql_query($sql, $link) or die(mysql_error());
$final = mysql_fetch_array($result);
?>

<DIV CLASS="content">
<DIV ID="leftcolumn">
Creator: <?php echo $final['Creator']; ?><BR>
Difficulty: <?php echo $final['Difficulty']; ?><BR>
Socks: <?php echo $final['Socks']; ?><BR>
<?php echo $final['Steps']; ?></DIV>
<DIV ID="rightcolumn"><IMG SRC="http://models.sockigami.com/images/models/<?php echo $final['ID']; ?>. <?php echo $final['ImageType']; ?>" ALT="<?php echo $final['Model']; ?>"></DIV></DIV>[/code]
Copy linkTweet thisAlerts:
@chesemonkylomaauthorSep 04.2006 — that doesnt work either, its the same thing just neater
Copy linkTweet thisAlerts:
@chesemonkylomaauthorSep 04.2006 — oh wait i read it wrong, sorry
Copy linkTweet thisAlerts:
@chesemonkylomaauthorSep 04.2006 — it works now thanks the little guy!
Copy linkTweet thisAlerts:
@The_Little_GuySep 04.2006 — np, It looks like you were trying to the array before you queryed you info.
×

Success!

Help @chesemonkyloma spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...