Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/hxrprodu/public_html/cost.php on line 9
Code <?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;
?>
Skype - Frostin8897 if you are a good coder, 2 have tried all have failed.
Change $sql to this:
Code $sql = mysql_query("SELECT SUM(`at`) FROM `User`") or trigger_error(mysql_error));
Then tell me what it says afterwards :D
Jul 11, 2012 02:55 AM
(This post was last modified: Jul 11, 2012 02:56 AM by FantaŠec.)
Parse error: syntax error, unexpected ')' in /home/hxrprodu/public_html/cost.php on line 7
Jul 11, 2012 02:57 AM
(This post was last modified: Jul 11, 2012 02:58 AM by Phizo.)
(Jul 11, 2012 02:55 AM)FantaŠec Wrote: Parse error: syntax error, unexpected ')' in /home/hxrprodu/public_html/cost.php on line 3
He made a mistake in the code.
PHP Code
<?php $sql = mysql_query("SELECT SUM(`at`) FROM `User`") or die(mysql_error());
The reason for the aforementioned snippet is that the error will contain a boolean when triggered, this way we will be able to determine what the error is and resolve the issue.
$sql = mysql_query("SELECT SUM(`at`) FROM `User`") or die(mysql_error());
Change the '9 to the snippet code ("
(Jul 11, 2012 02:57 AM)Phizo Wrote: He made a mistake in the code.
PHP Code
<?php $sql = mysql_query("SELECT SUM(`at`) FROM `User`") or die(mysql_error());
The reason for the aforementioned snippet is that the error will contain a boolean when triggered, this way we will be able to determine what the error is and resolve the issue.
Oh sorry, I did make a mistake :(
Yeah that is what I was trying to do, it makes it easier to determine the error I'm pretty sure :D
It says Error now, nothing else, any ideas?
(Jul 11, 2012 03:02 AM)FantaŠec Wrote: It says Error now, nothing else, any ideas?
There's obviously a mistake in your query, most likely to do with the table and/or column. It should say more than just "Error" though.
Everything is correct though, thats the problem :/
I am working in this now, I will get back to you when I have found it :D
put ds b4 the the sql query
PHP Code
<?php mysql_select_db("DATABASE_NAME");
btw, the php errors lets you know where to correct,
Warning:
PHP Code
<?php mysql_fetch_array()
expects parameter 1 to be resource, boolean given in
Means $sql is returing
~BadGame🤝
It still wont work 😧 does anyone have Skype or TV?
(Jul 11, 2012 09:24 AM)FantaŠec Wrote: It still wont work 😧 does anyone have Skype or TV?
are u using hostzilla ???
in the free version the mysql installed in buggy 🤮
when they was migrating :)
Jul 11, 2012 10:19 AM
(This post was last modified: Jul 11, 2012 10:21 AM by FantaŠec.)
No I am not :( I am using a host I am not sure of XD
I DID IT, I DO NOT KNOW WHAT I DID BUT I DID IT :)))) I just fixed something that looked bad and its fixed. But who gets 5$ 😧 lol
(Jul 11, 2012 10:19 AM)FantaŠec Wrote: No I am not :( I am using a host I am not sure of XD
I DID IT, I DO NOT KNOW WHAT I DID BUT I DID IT :)))) I just fixed something that looked bad and its fixed. But who gets 5$ 😧 lol
save it in the pocket or Have an icecream of it 😁
|