Results 1 to 2 of 2

Thread: PHP Help.

  1. #1
    Join Date
    Jan 2009
    Location
    UK
    Posts
    42
    Tokens
    0

    Default PHP Help.

    PHP Code:
    <?php
    session_start
    ();
    require (
    "connect.php");
    require(
    "functions.php"); 
    include(
    "template/header.php");

    if(!isset(
    $_SESSION['status'])){
        die(
    'You need to <a href="login.php">login</a> before you can access the members area!');
    }
        if(
    $_SESSION['id'] != $_GET['user']){
        die (
    'Error');
        
        
        }else{
        
    $offer mysql_real_escape_string($_GET['offer']);
        
    $user mysql_real_escape_string($_GET['user']);
        
    $title mysql_real_escape_string($_GET['title']);
        
    $username mysql_real_escape_string($_GET['username']);
        
    $value1 mysql_query("SELECT * FROM offers WHERE id='$offer'");
        
    $value2 mysql_fetch_array($value1);
        
    $value $value2['value'];
        
    $date date('Y-m-d H:i:s');  
        
    $ip $_SERVER['REMOTE_ADDR'];
        
    $status "0";
    $result mysql_query("SELECT * FROM users WHERE id='$user'");
    $valueoffer mysql_fetch_array($result);
    $valueamount $valueoffer['pending'];
    $newpending $valueamount $value
    $username $valueoffer['username']; // I'm assuming 'username' is the name of you username field. Amend if incorrect.



    $result mysql_query("SELECT * FROM offers WHERE id='$title'");
    $offertitle mysql_fetch_array($result);
    $otitle $offertitle['offername'];


    // table, field and value should all be replaced according to your table  


    mysql_query("INSERT into offersUSERS VALUES(NULL, '$username', '$offer', '$otitle', '$status', '$value', '$ip', '$user', '$date')");  
        
        
    mysql_query("UPDATE users SET pending='$newpending' WHERE id='$user'");
        echo 
    "Done! You will be credited as soon as an administrator approves the offer! <a href=\"members.php\">return?</a>";
        }
                include(
    "template/footer.php");
    ?>
    Here's my code, it currently updates the table 'username' in my database. But I can't get it to update 'offertitle'. Why?

  2. #2
    Join Date
    Feb 2009
    Posts
    131
    Tokens
    0

    Default

    PHP Code:
    mysql_query("INSERT into offersUSERS VALUES(NULL, '$username', '$offer', '$otitle', '$status', '$value', '$ip', '$user', '$date')"); 
    Basic syntax of your insert query isn't working out.

    PHP Code:
    mysql_query"INSERT INTO `offersUSERS` (table1, table2, table3) VALUES('value1', 'value2', 'value3') " ); 
    Containing table information like the table name, where you've not bothered to use `table` - is not really neat, as you can see my version looks a lot neater.

    You didn't define what columns need to be updated, so that explain's why it wasn't working.

Posting Permissions

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