Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Why have you dropped the $_POST superglobal variable assignments? That's how the data is passed from the function. Also, the mysql_real_escape_string() should be after a mysql connection.

    PHP Code:
    <?php

    $db_host 
    =  <defined>
    $db_user =  <defined>
    $db_pwd = <defined>
    $database = <defined>
    $table =<defined>

    if (!
    mysql_connect($db_host$db_user$db_pwd))
        die(
    "Can't connect to database");

    if (!
    mysql_select_db($database))
        die(
    "Can't select database");

    $tval mysql_real_escape_string($_POST['tval']);
    $cval mysql_real_escape_string($_POST['cval']);

    $sql mysql_query("DELETE FROM expedia WHERE `tag`='$tval' AND `cpm`=$cval" );
    if (!
    $sql) {
        die(
    mysql_error());
    }



    mysql_free_result($result);

    ?>
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  2. #17
    New Coder
    Join Date
    Jul 2012
    Posts
    73
    Thanks
    4
    Thanked 0 Times in 0 Posts
    ok, i've made those changes.. and am whitescreened... still not working..

    see file:

    Code:
    <?php
    
    $db_host = 
    $db_user = 
    $db_pwd = 
    $database = 
    $table = 
    
    
    if (!mysql_connect($db_host, $db_user, $db_pwd))
        die("Can't connect to database");
    
    if (!mysql_select_db($database))
        die("Can't select database");
    
    $t = mysql_real_escape_string($_POST['tval']);
    $c = mysql_real_escape_string($_POST['cval']);
    settype($c, 'float');
    
    $sql = mysql_query("DELETE FROM {$table} WHERE `tag` = '$t' AND `cpm` = $c" );
    
    if (!$sql) {
        die(mysql_error());
    }
    else  {
    echo "Well.. They're gone.. for good..";
    echo "<BR>";
    echo "<a href='pyflightsearchresults.php'>Back to Results</a>";
    }
    
    
    echo "<a href="pyflightsearchresults.php">That's it. They're gone.. you can't get them back.. gone forever...  click here to return to strikesearch results</a>";
    
    mysql_free_result($result);
    
    ?>
    I have placed vardump on the 2 variables.. and they show good to that point:
    float(9) string(8) "testing3"
    in firebug i see the post values & 500 internal server error
    Last edited by stevenryals; 11-13-2012 at 01:27 AM.

  3. #18
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    if you're getting "white screened", it's usually because the PHP encountered a problem whilst executing, and you don't have error reporting on. Check your error log.
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  4. #19
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Why are you casting $c to a float btw? Also, you shouldn't really mix your coding styles (concerning your two different if styles). In my opinion, curly brackets are ALWAYS the best, so i'd suggest using that for all your if statements.
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  5. #20
    New Coder
    Join Date
    Jul 2012
    Posts
    73
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Changing $c to float to match the database..
    I made the if/else changes as well

    It seems to be working.. at the moment, thank god.

    I appreciate the help.. sorry to be such a pain..

    Thanks again.. hopefully i can keep learning and contribute to others on this forum.


 
Page 2 of 2 FirstFirst 12

Posting Permissions

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