PHP MySql Not working

Discussion in 'PHP' started by laces12, Jun 11, 2010.

  1. #1
    Hi, I have a game I am making, and in one of the files, php will decide if it wants to exacute the sql. If someone could look at it, that would be nice.
    
    <?php
    if (!isset($_SESSION))
    {
    	session_start();
    }
    $bullshit = true; //Cause im mad and it's not working
    if ($bullshit) {
    include "header.php";
    $con2 = mysql_connect($dhost, $dusername, $dpassword) or die("Cannot Connect"); 
    mysql_select_db($ddatabase, $con2);
    $id = 100;//halen("select id from us_members where username='".$_COOKIE['Username']."' ");
    $iId = 5;//halen("select itemId from us_items where ownerId='".$id."' && id='".$_GET['itemid']."'");
    $top = 't';//halen("SELECT type from us_itemTypes WHERE itemid='".$iId."'");
    $inuse = halen("SELECT inuse FROM us_items WHERE id='50'");
    
    if ($iId == '' || $iId == null) {
    echo "You don't own this item!";
    include "footer.php";
    exit;
    }
    $item = mysql_query("select * from us_itemTypes where itemId=$iId limit 1");
    $item = mysql_fetch_array($item);
    
    if ($inuse == 0){
    
    if ($top == "t"){
    mysql_query("Update us_members set c_top='5' where username='jerry'",$con2);
    }
    
    mysql_query("Update us_items set inuse='1' where id='50'",$con2);
    mysql_query("Update us_members set def=def+10 where username='jerry' limit 1",$con2);
    echo "Item has been equipped!";
    
    } else {
    
    if ($top == "t"){
    mysql_query("Update us_members set c_top='0' where username='jerry'",$con2);
    }
    mysql_query("Update us_items set inuse='0' where id='50'",$con2);
    mysql_query("Update us_members set def=def-10 where username='jerry' limit 1",$con2);
    echo "Item has been un-equipped!";
    
    }
    }
    include "footer.php";
    
    Code (markup):
    That is the whole page, but
    
    if ($inuse == 0){
    
    if ($top == "t"){
    mysql_query("Update us_members set c_top='5' where username='jerry'",$con2);
    }
    
    mysql_query("Update us_items set inuse='1' where id='50'",$con2);
    mysql_query("Update us_members set def=def+10 where username='jerry' limit 1",$con2);
    echo "Item has been equipped!";
    
    } else {
    
    if ($top == "t"){
    mysql_query("Update us_members set c_top='0' where username='jerry'",$con2);
    }
    mysql_query("Update us_items set inuse='0' where id='50'",$con2);
    mysql_query("Update us_members set def=def-10 where username='jerry' limit 1",$con2);
    echo "Item has been un-equipped!";
    }
    
    Code (markup):
    is the part not working. :cry:
     
    laces12, Jun 11, 2010 IP
  2. bbBoy

    bbBoy Peon

    Messages:
    92
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    :)

    What kind of error are you getting that's stopping you? I see tons of stuff wrong that could potentially stop this from executing...
     
    bbBoy, Jun 11, 2010 IP
  3. laces12

    laces12 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thats the problem. There is no error. It simple doesn't exacute the mysql. It does everything else.
     
    laces12, Jun 11, 2010 IP
  4. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #4
    Whether first it can able to connect to your mysql??
     
    roopajyothi, Jun 12, 2010 IP