Fix this error Please :(

Started on the old forum in July 2012 · view the original in the archive · old links redirect here

1 reply · 398 views · started 14 years ago · 1 min read

2 participants
RDXZ Newbie · 5 posts #1

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/damm/public_html/cost.php on line 9

<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
{
 die('error');
}
$sql = mysql_query("SELECT SUM(`at`) FROM `User`");
$r = mysql_fetch_array($sql);
$total=$r[0];
echo $total;
?>

please guys do something 🙂

softwarefreak Senior · 349 posts #2

RDXZ wrote: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/damm/public_html/cost.php on line 9

<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
{
 die('error');
}
$sql = mysql_query("SELECT SUM(`at`) FROM `User`");
$r = mysql_fetch_array($sql);
$total=$r[0];
echo $total;
?>

please guys do something :)

are you trying to prove yourself a noob? 😀 put ds b4 the the sql query

mysql_select_db("DATABASE_NAME");

btw, the php errors lets you know where to correct, Warning:

mysql_fetch_array()

expects parameter 1 to be resource, boolean given in Means $sql is returing

FALSE

I need some facebook likes, can you please help me 🤝 http://facebook.com/softwarefreakin I noticed social media is really powerful 🧙 Well DONE is better than well SAID

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close