Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8477385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:27:13+00:00 2026-06-10T18:27:13+00:00

Sorry for the badly phrased title, I don’t know what else to call this

  • 0

Sorry for the badly phrased title, I don’t know what else to call this situation.

Here’s my dilemma, for fun I’m making a little doodad so people can submit the name, platform, and location of Battlefield 3 servers so they no longer need to rely on word of mouth.

This older code works fine, it deletes records and does it’s job.

<?php

mysql_connect('localhost', 'root', 'pass');
mysql_select_db('database');

$server_secret = mysql_real_escape_string($_POST['secret_initial']);
$server_confirm = mysql_real_escape_string($_POST['secret_verify']);

if ($server_secret == $server_confirm) {
    echo "Both matched.";
    if ((strlen($server_secret) < 6) and (strlen($server_verify) < 6)) {
        echo "Password too short.";
    } else {
        echo "Password is of proper length.";
        $sql = "DELETE FROM `servers` WHERE secret='" . sha1($server_secret) . "'";
        mysql_query($sql) or die("Couldn't delete record. " . mysql_error());
    }
} else {
    echo "Mismatch.";
}

?>

However, if I use this:

<?php

mysql_connect('localhost', 'root', 'pass');
mysql_select_db('database');

// Create variables from form
$server_secret = mysql_real_escape_string($_POST['secret_initial']);
$server_confirm = mysql_real_escape_string($_POST['secret_verify']);

// Check for verification
if ($server_secret == $server_confirm) {
    // Delete from database
    $sql = "DELETE FROM `servers` WHERE secret='" . sha1($server_secret) . "'";
    if (mysql_query($sql) or die("Couldn't delete record. " . mysql_error()) {
        $success = true;
    } else {
        $success = false;
    }
}

?>

It always reports $success as true, even when it is false, and what also confuses me is even when both the secret and verification are correct the entry isn’t removed from the MySQL database.

The older version works fine though. That’s what baffles me.

The same method I used for checking success (if (mysql_query($sql)) worked fine for insertion and actually gives me feedback if it fails as it should, but for some reason it always reports success when I attempt to delete a record.

If anyone can help me out here I’d really appreciate it.

Please note: I’m very much a novice with PHP/MySQL, so please forgive me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:27:15+00:00Added an answer on June 10, 2026 at 6:27 pm

    This is because the query is syntactically correct, so there’ll never be an error. Instead, you want to find the number of rows that were actually affected:

    <?php
    
    mysql_connect('localhost', 'root', 'pass');
    mysql_select_db('database');
    
    // Create variables from form
    $server_secret = mysql_real_escape_string($_POST['secret_initial']);
    $server_confirm = mysql_real_escape_string($_POST['secret_verify']);
    
    // Check for verification
    if ($server_secret == $server_confirm) {
        // Delete from database
        $sql = "DELETE FROM `servers` WHERE secret='" . sha1($server_secret) . "'";
        $result = mysql_query($sql);
        if (mysql_affected_rows($result)) {
            $success = true;
        } else {
            $success = false;
        }
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry, for the badly phrased title. I don't know much object-oriented PHP, so, I
Sorry for the badly formatted title, but I don't know how to explain this
Sorry, I know this question is easy, but I don't know how to get
Sorry for the bad title - I simply do not know what to call
Sorry for the badly worded title, I currently have this if statement: - if
Sorry for a badly-phrased question. I have a requirement coming from a non-technical person
It's a badly worded title but I can't come up with anything better, sorry!
Sorry about the cranky title, here's the example: <table> <tr> <th class=hey-1-aa></th> </tr> <tr>
Sorry for the badly-worded title. I've been looking through the documentation, but I cannot
Sorry for this simple question, but I can't solve it... There is an example:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.