Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 6 of 6

Thread: PHP HELP - EROR

  1. #1

    Default PHP HELP - EROR

    Hi, Everbody

    Unsure Have to Fix this any ideas ?


    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in
    Selling Shoutcast!

  2. #2
    Join Date
    Apr 2008
    Location
    Derby
    Posts
    4,668
    Tokens
    262

    Latest Awards:

    Default

    Post your code.
    Back for a while

  3. #3

    Default

    <?
    session_start();

    if (!(isset($_SESSION["real_name"])))
    {
    //echo "I'm not logged in";
    header('Location: login.php');
    }
    else
    {
    echo "";
    }


    ?>



    <html>
    <head>
    <title>Mafia-Assassins :: Kill</title></head>
    <link REL="stylesheet" TYPE="text/css" HREF="main.css">

    <script language=javascript src=Menus.js></script>

    <body background="wallpaper.jpg">
    <center>
    <table border="0" cellspacing="0" cellpadding="0" align="center" width="95%" class="cat">

    <TR>

    <TD width="150" background="tdbg3.jpg" bgcolor="#222222" valign="top">
    <?php include("leftmenu.php");?>
    </TD>

    <td width="100%" valign="top"> <br>



    <?

    include_once "includes/db_connect.php";
    include_once"includes/functions.php";
    include_once "includes/jail_check.php";
    include_once "includes/hospital_check.php";

    $username=$_SESSION['real_name'];

    $select2 = mysql_query("SELECT * FROM jail WHERE username='$username'");
    $num2 = mysql_num_rows($select2);

    if ($num2 <=0){

    $select2 = mysql_query("SELECT * FROM hospital WHERE username='$username'");
    $num2 = mysql_num_rows($select2);

    if ($num2 <=0){

    $sql="SELECT * from search WHERE username='$username'";
    $result=mysql_query($sql);

    while($rows=mysql_fetch_array($result)){ // Start looping table row

    $timeleft = $rows['time'];
    $target = $rows['target'];
    $id = $rows['id'];
    $status = $rows['status'];
    $hours = $rows['hours'];


    $time=time();
    $safe=mysql_num_rows(mysql_query("SELECT * FROM safe WHERE username='$a->target' AND time > '$time'"));

    $timecheck = $timeleft - time() ;

    if ($timecheck <0 && $status < 2 && $hours < 4){
    mysql_query("UPDATE search SET status='1' WHERE id='$id'");
    }elseif($timecheck <0 && $hours >=4 || $userlevel >=15){

    $sql2="SELECT * from users WHERE username='$target'";
    $result2=mysql_query($sql2);

    while($rows2=mysql_fetch_array($result2)){ // Start looping table row

    $target_country = $rows2['country'];
    }

    mysql_query("UPDATE search SET status='2', location='$target_country' WHERE id='$id'");

    }

    }


    if(strip_tags($_GET['dl'])){
    $check=mysql_num_rows(mysql_query("SELECT * FROM search WHERE id='$dl' AND username='$username'"));
    if ($check !="0"){
    mysql_query("DELETE FROM search WHERE id='$dl'");
    echo "Search deleted!";
    }}


    if (strip_tags($_POST['kill']) && strip_tags($_POST['kill_name']) && strip_tags($_POST['kill_bullets'])){

    $kill_name = $_POST['kill_name'];
    $kill_name = strip_tags($kill_name);
    $kill_bullets = $_POST['kill_bullets'];
    $kill_bullets = strip_tags($kill_bullets);

    $target=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$kill_name'"));
    $fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'"));

    if ($kill_bullets == 0 || !$kill_bullets || ereg('[^0-9]',$kill_bullets)){
    echo "You cannot shoot that amount!";

    }elseif ($kill_bullets != 0 || $kill_bullets || !ereg('[^0-9]',$kill_bullets)){

    $user_true=mysql_num_rows(mysql_query("SELECT * FROM users WHERE username='$kill_name'"));

    if ($user_true == "0"){
    echo"This user does not excist!";
    }elseif ($user_true != "0"){

    if ($kill_bullets > $bullets){

    echo "You dont have that amount of bullets!";

    }elseif($kill_bullets <= $bullets){

    if ($target->userlevel >=10 && $userlevel <15){

    echo "You can not kill a staff member!";

    }else{


    if ($nextshoot >= time()){

    echo "You have to wait until you can make your next kill!";

    }else{

    if (strtolower($target->username) == strtolower("ChrisStrydes") && $missionid == 2){

    $rand = rand(8000,10000);
    $rand2 = rand($rand,13000);
    $rand3 = rand(10,55);

    if ($kill_bullets >= $rand){

    $newadd = rand(3000000,5333333);
    $newadd2 = number_format($newadd);

    mysql_query("UPDATE users SET `mission`=`mission`+'1', `cash`=`cash`+'$newadd', bullets=bullets-'$kill_bullets' WHERE username='$username'");
    mysql_query("UPDATE users SET mail='1', bullets=bullets+'$rand2' WHERE username='$username'");
    $rand2 = number_format($rand);

    mysql_query("INSERT INTO `messages` ( `id` , `t` , `f` , `message` , `date` , `r` , `saved` ) VALUES (
    '', '$username', '$username', 'You recieved <b>$$newadd2</b> and <b>$rand2</b> bullets from rescuing the president pt2, please check missions for your next mission!', '$date', '0', '0')");
    mysql_query("INSERT INTO `logs` ( `id` , `who` , `action` , `date` , `ip` ) VALUES ('', '$username', 'Recieved $<b>$newadd2</b> from the second mission!', '$date, '$realip')");


    echo "You shot at <b>ChrisStrydes</b>, He died from the shots!";
    }else{

    mysql_query("UPDATE users SET bullets=bullets-'$kill_bullets', health='$rand3' WHERE username='$username'");

    echo "You shot at <b>ChrisStrydes</b>, He survived from the shots. He shot back at you!";

    }

    }else{

    if ($target->missioncharc >=1){

    echo "You can not kill a mission character!";

    }else{

    if ($target->status == "Dead" || $target->status == "Banned"){
    echo "That user is already dead!";

    }elseif ($target->status != "Dead" && $target->status != "Banned"){

    $a_query = mysql_query("SELECT * FROM search WHERE target='$kill_name' AND status='2' AND username='$username'");
    $check_found=mysql_num_rows($a_query);

    if ($check_found == "0"){
    echo "You have not found this user yet or they have traveled to another location!";

    }else{

    $a_query = mysql_query("SELECT * FROM BG WHERE username='$kill_name'");
    $check_found=mysql_num_rows($a_query);

    if ($check_found >= 1 && $target->bglevel >=1 || $check_found >= 1 && $target->nbglevel >=1){

    $bg = mysql_query("SELECT * FROM BG WHERE status='Accepted' AND username='$kill_name' ORDER by id ASC LIMIT 1");
    while ($i = mysql_fetch_object($bg)){

    $bg1 = $i->bg;
    }

    echo "This user has a bodyguard called <b>$bg1</b>, you need to kill <b>$bg1</b> before you can kill <b>$kill_name</b>!";

    }else{


    if ($target->last_attempted > time()){
    echo "This target is still recovering!";
    }else{
    if (strtolower($username) == strtolower($kill_name)){
    echo "You cannot kill yourself!";
    }elseif(strtolower($username) != strtolower($kill_name)){

    if ($fetch->gun == "None"){
    echo "How do you expect to kill someone without no weapon!";
    }elseif($fetch->gun != "None"){
    if ($fetch->country != $target->country){
    echo "You need to be in the same country as this user.";
    }elseif ($fetch->country == $target->country){

    $target=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$kill_name'"));
    $fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'"));

    if ($rank == "Minor"){ $killerranking="1";}
    elseif ($rank == "Wasteman"){ $killerranking="2";}
    elseif ($rank == "Thug"){ $killerranking="3";}
    elseif ($rank == "Badman"){ $killerranking="4";}
    elseif ($rank == "Respectable Badman"){ $killerranking="5";}
    elseif ($rank == "Assassin"){ $killerranking="6";}
    elseif ($rank == "Respectable Assassin"){ $killerranking="7";}
    elseif ($rank == "Boss"){ $killerranking="8";}
    elseif ($rank == "Respectable Boss"){ $killerranking="9";}
    elseif ($rank == "Godfather"){ $killerranking="10";}
    elseif ($rank == "Legendary Godfather"){ $killerranking="11";}
    elseif ($rank == "Don"){ $killerranking="12";}
    elseif ($rank == "Respectable Don"){ $killerranking="13";}
    elseif ($rank == "Global Threat"){ $killerranking="14";}
    elseif ($rank == "Ultimate Assassinator"){ $killerranking="15";}

    if ($target->rank == "Minor"){$victimranking="1";}
    elseif ($target->rank == "Wasteman"){$victimranking="2";}
    elseif ($target->rank == "Thug"){$victimranking="3";}
    elseif ($target->rank == "Badman"){$victimranking="4";}
    elseif ($target->rank == "Respectable Badman"){$victimranking="5";}
    elseif ($target->rank == "Assassin"){$victimranking="6";}
    elseif ($target->rank == "Respectable Assassin"){$victimranking="7";}
    elseif ($target->rank == "Boss"){$victimranking="8";}
    elseif ($target->rank == "Respectable Boss"){$victimranking="9";}
    elseif ($target->rank == "Godfather"){$victimranking="10";}
    elseif ($target->rank == "Legendary Godfather"){$victimranking="11";}
    elseif ($target->rank == "Don"){$victimranking="12";}
    elseif ($target->rank == "Respectable Don"){$victimranking="13";}
    elseif ($target->rank == "Global Threat"){$victimranking="14";}
    elseif ($target->rank == "Ultimate Assassinator"){$victimranking="15";}


    $killerrank = $killerranking+1;
    $victemrank1 = $victimranking+1;
    $victemrank = $victemrank1*2;
    $killergun = $fetch->gunid+1;
    $victemprotection1 = $target->protectionid+1;
    $victemprotection = $victemprotection1/2;
    $killerstat = $killerrank*$killergun;
    $victemstat = $victemrank*$victemprotection;
    $bothstat = $victemstat/$killerstat;
    $killneeded = $bothstat*174;
    $percentdamage = round($kill_bullets/$killneeded);
    $cashadd=rand(5,19);
    $percent = $target->bullets * $cashadd;
    $percentadd = $percent / 100 ;
    $add =3600*3;
    $last=time()+$add;

    $time=gmdate('Y-m-d h:i:s');

    //print"<br>$defense - $power<br>";

    $new_bullets=$fetch->bullets - $kill_bullets;
    if($target->health<=$percentdamage){
    $now=time()+3600;
    $date = gmdate('Y-m-d h:i:s');
    $last=time()+(3600*2);
    $kill_bullets2=number_format($kill_bullets);
    $hit_money=mysql_fetch_object(mysql_query("SELECT SUM(amount)AS jackpot FROM hitlist WHERE target='$target->username'"));

    $your_money=$fetch->cash + $hit_money->jackpot;
    echo "You shot at <b>$kill_name</b> he died from the shots, you received $cashadd% of this user's bullets!";

    mysql_query("DELETE FROM BG WHERE bg='$target->username'");
    mysql_query("UPDATE users SET status='Dead', last_attempted='$last', killer='Got Killed by <b>$username</b> with $kill_bullets2 bullets!' WHERE username='$kill_name' LIMIT 1");
    mysql_query("UPDATE users SET bullets=bullets-'$kill_bullets', cash=cash+'$hit_money->jackpot',`totalkills`=`totalkills`+'1', `bullets`=`bullets`+'$percentadd' WHERE username='$username' AND bullets >= '$kill_bullets' LIMIT 1");
    mysql_query("DELETE FROM hitlist WHERE target='$target->username'");
    mysql_query("INSERT INTO `attempts` (`id`, `username`, `target`, `outcome`, `date`) VALUES ('', '$username', '$target->username', 'Dead', '$date')");
    mysql_query("INSERT INTO `logs` ( `id` , `who` , `action` , `date` , `ip` ) VALUES ('', '$username', 'Killed <b>$target->username</b> with $kill_bullets2 bullets and received $percentadd bullets!', '$date, '$realip')");

    $select = mysql_query("SELECT * FROM crews WHERE owner='$kill_name'");
    $num = mysql_num_rows($select);

    if ($num > 0){

    $rhm = mysql_query("SELECT * FROM users WHERE crew ='$target->crew' AND status='Alive' AND userlevel <5 ORDER by rankpoints DESC LIMIT 1");
    while ($i = mysql_fetch_object($rhm)){

    $rhm1 = $i->username;
    }
    $rhmnum = mysql_num_rows($rhm);

    if ($rhmnum==0){

    mysql_query("DELETE FROM crews WHERE owner='$kill_name'");
    mysql_query("UPDATE users SET crewlevel='0', crew='None' WHERE crew='$target->crew'");
    }else{
    mysql_query("UPDATE crews SET owner='$rhm1' WHERE name='$target->crew' LIMIT 1");
    mysql_query("UPDATE users SET crewlevel='9' WHERE username='$rhm1' LIMIT 1");
    mysql_query("UPDATE users SET crewlevel='2' WHERE username='$kill_name' LIMIT 1");

    }}
    /////GIVE WITNESS STATEMENT/////

    $witnessessent = 0;
    while($witnessessent<=8){
    $maxid = mysql_fetch_array(mysql_query("SELECT id FROM users WHERE health>0 AND online='Online' ORDER BY id DESC LIMIT 1"));
    $randomuserid = rand(1,$maxid["id"]);
    $tempvar1 = mysql_query("SELECT username,id FROM users WHERE id='$randomuserid' LIMIT 1");
    while($tempvar2 = mysql_fetch_array($tempvar1)){
    $gettingname = $tempvar2["username"];
    $touserid = $tempvar2["id"];
    if($gettingname!=$username){

    mysql_query("INSERT INTO `messages` ( `id` , `t` , `f` , `message` , `date` , `r` , `saved` ) VALUES (
    '', '$gettingname', '$gettingname', 'You witnessed <b>$username</b> kill <b>$target->username</b>!', '$date', '0', '0')");

    $witnessessent++;
    }
    }
    }


    ///FAILED////
    }else { echo "You shot at $kill_name he survived from the shots!";
    $new_health_target=$target->health;
    $it=$kill_bullets / 2;
    $test= rand(5,50);
    $new_health_target = $target->health - $test;
    $ttt = 3600 * 5 ;
    $failednext= time() + $ttt;
    $now=time()+3600;
    $add =3600*3;
    $last=time()+$add;
    $new_bullets=$fetch->bullets - $kill_bullets;
    mysql_query("UPDATE users SET health=health-'$percentdamage', last_attempted='$last' WHERE username='$target->username'");
    mysql_query("UPDATE users SET bullets=bullets-'$kill_bullets', nextshoot='$failednext' WHERE username='$username'");
    mysql_query("INSERT INTO `attempts` (`id`, `username`, `target`, `outcome`, `date`) VALUES ('', '$username', '$target->username', 'Survived', '$date')");

    }}

    }}}}}}}}}}

    }}

    ///Mission check///
    }}
    ////


    /////////CLASSING NEEDS TO GO IN THE BRACKET ABOVE



    /////BASICALLY WHAT I NEED TO DO IS CLASS EACH WEAPON FOR A CERTIAN AMOUNT OF POINTS ADD THEM ALL UP THEN COMPARE THEM TO THE USERS DEFENCE **** ADDED UP.
    /////tHEN DECIDE WETHER OR NOT TO KILL THEM.


    if (strip_tags($_POST['find']) && strip_tags($_POST['find_name']) && strip_tags($_POST['find_time'])){

    $find_name = $_POST['find_name'];
    $find_name = strip_tags($find_name);
    $find_time = $_POST['find_time'];
    $find_time = strip_tags($find_time);

    $target=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$find_name'"));


    if ($find_time == 0 || !$find_time || ereg('[^0-9]',$find_time)){

    echo "Invalid time!";

    }elseif ($find_time != 0 || $find_time || !ereg('[^0-9]',$find_time)){


    if (strtolower($find_name) == strtolower($username))
    {

    echo "You can not search for yourself!!";
    }else{


    $sql="SELECT * from users WHERE username='$find_name'";
    $result=mysql_query($sql);

    while($rows=mysql_fetch_array($result)){ // Start looping table row

    $sendercash= $rows['cash'];
    $level= $rows['userlevel'];
    $clevel= $rows['crewlevel'];

    }
    if ($level >=10 && $userlevel <15){


    echo "You can not search for a staff member!";

    }else{

    $num_true=mysql_num_rows($result);
    if ($num_true == 0){
    echo "No such user!";
    }elseif ($num_true != 0){

    $sql2="SELECT * from search WHERE target='$find_name' AND username='$username'";
    $result2=mysql_query($sql2);

    $num_true=mysql_num_rows($result2);
    if ($num_true >= 1){
    echo "You are already searching for this user!";
    }elseif ($num_true <= 1){

    $sql2="SELECT * from search WHERE username='$username'";
    $result2=mysql_query($sql2);

    $num_true2=mysql_num_rows($result2);

    if ($num_true2 >= 3){
    echo "You can not have more than 3 searches out!";
    }else{

    if ($target->missioncharc >=1 && $target->username!="ChrisStrydes"){

    echo "You can not search for a mission character!";

    }else{

    $total_time=time()+(3600*$find_time);

    mysql_query("INSERT INTO `search` (`id`, `username`, `target`, `time`, `status`, `location`, `hours`) VALUES ('', '$username', '$find_name', '$total_time', '0', '', '$find_time')");


    echo "Searches are now out!";



    }}}}}}}

    ///MISSION CHECK!
    }
    ?>
    <br>
    <form action="" method="post">
    <table border="1" class="sub2" align="center" cellspacing="0" cellpadding="2" bordercolor=black width=50%>
    <tr>
    <td align="center" colspan="5" class="header">Kill</td>
    </tr>
    <tr>
    <td width="25%">Name:</td>
    <td width="75%">
    <center><input name="kill_name" type="text" id="kill_name3" style="border:1px solid black;" size="20"></center></td>
    </tr>
    <tr>
    <td>Bullets:</td>
    <td>
    <center><input name="kill_bullets" type="text" id="kill_bullets3" style="border:1px solid black;" size="20"></center></td>
    </tr>
    <tr>
    <td align="center" colspan="5"><input name="kill" type="submit" id="kill_button3" value="Shoot" /></td>
    </tr>
    </table>
    <br>
    <br>
    <table border="1" class="sub2" align="center" cellspacing="0" cellpadding="2" bordercolor=black width=50%>
    <tr>
    <td align="center" colspan="5" class="header">Search</td>
    </tr>
    <tr>
    <td width="25%" align="center">Find:</td>
    <td align="center"><input name="find_name" type="text" id="find_name2" style="border:1px solid black;" size="20"></td>
    </tr>
    <tr>
    <td width="25%" align="center">Hours:</td>
    <td align="center"><input name="find_time" type="text" id="find_time2" style="border:1px solid black;" size="20"></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td align="right">
    <input name="find" type="submit" id="hunt_button23" value="Search" /></td>
    </tr>
    </table>
    </form>
    <br><br>
    <table border="1" class="sub2" align="center" cellspacing="0" cellpadding="2" bordercolor=black width=50%>
    <tr>
    <td align="center" colspan="5" class="header">Searches Out</td>
    </tr>
    <?php $my=mysql_query("SELECT * FROM search WHERE username='$username'");
    $humm=mysql_num_rows($my);
    if ($humm == "0"){
    echo "<tr>
    <td colspan=5><center>You currently have no searches!</center></td>
    </tr>";
    }
    while($i=mysql_fetch_object($my)){

    echo "<tr>";
    echo " <td width=20% height=10><a href='viewprofile.php?viewuser=$i->target'>$i->target</a></td>";
    echo " <td width=60%>"; if ($i->status == "0"){ echo "".maketime($i->time).""; }elseif ($i->status == "1"){ echo "Not found"; }elseif ($i->status == "2"){ echo "The detective found $i->target in $i->location!"; } echo "</td>";
    echo "<td width=20%><a href='?dl=$i->id'>Delete</a></td>";
    echo " </tr>";

    }
    ?>
    </table>


    <?
    //Hospital/Jail check

    }}

    ?>



    </td>



    <TD width="150" valign="top">
    <?php include("rightmenu.php");?>
    </TD>

    </TR>


    </table>

    </center>
    </body>
    </html>

    ---------- Post added 25-07-2010 at 04:39 PM ----------

    DO YOU WANT NUMBER OF THE LINES THAT HAS ERRORS ?
    Selling Shoutcast!

  4. #4
    Join Date
    Apr 2010
    Location
    Newcastle
    Posts
    655
    Tokens
    50

    Default

    That could be caused when your SQL queries are invalid or if your table/field names are wrong - have you set up the database properly?

    Just a note - in future could you post the code within [PHP ] [/ PHP] tags.
    Last edited by Apolva; 25-07-2010 at 05:57 PM.

  5. #5
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    It means which ever line it says the error is on, it can not fetch the data it if trying to fetch, main cause: Table doesnt exist.

    Make sure you have installed your database

    Lew.
    Im not here to be loved, I love to be hated :-}


  6. #6
    Join Date
    Oct 2007
    Posts
    824
    Tokens
    71

    Latest Awards:

    Default

    You didn't create the tables. That script should come with a .sql file.
    Vouches
    [x][x]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •