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 669593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:10:04+00:00 2026-05-14T00:10:04+00:00

Why do I get a mysql_query(): supplied argument is not a valid for the

  • 0

Why do I get a “mysql_query(): supplied argument is not a valid” for the first…

$r = mysql_query($q, $connection);

In the following code…

$bId    = trim($_POST['bId']);
$title  = trim($_POST['title']);
$story  = trim($_POST['story']);

$q  = "SELECT * ";
$q .= "FROM " . DB_NAME . ".`blog` ";
$q .= "WHERE `blog`.`id` = {$bId}";
$r = mysql_query($q, $connection);
//confirm_query($r);
if (mysql_num_rows($r) == 1) {      
    $q  = "UPDATE " . DB_NAME . ".`blog` SET
                        `title` = '{$title}',
                        `story` = '{$story}'
                    WHERE `id` = {$bId}";
    $r = mysql_query($q, $connection);
    if (mysql_affected_rows() == 1) {
        //Successful
        $data['success'] = true;
        $date['errors']  = false;
        $date['message'] = "You are the Greatest!";
    } else {
        //Fail
        $data['success'] = false;
        $data['error']   = true;
        $date['message'] = "You can't do it fool!";
    }        
}

I also get an “mysql_num_rows(): supplied argument is not a valid MySQL result resource” error too.

Side notes: I am using 1&1 Hosting (worst hosting ever), custom .htaccess file with one line text to enable PHP 5.2 (only way with 1&1 Hosting).


Extra stuff add after the questions was posted…

Here is how $connection is defined. It is on its own page called connection.php that is called up using the require_once function. It it is called up on every page that require a database connection including the one in question…

$connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS);
    if (!$connection) {
        die("Database Connection Failed: </br>" . mysql_error());
    }
    $db_select = mysql_select_db(DB_NAME,$connection);
    if (!$db_select) {
        die("Database Selection Failed: </br>" . mysql_error());
    }

… I know it is working because this the same connect that I use for the page I have and I have no problems with it. I havent testing on my home server yet, but I am going to later to see if it is related to a 1&1 Hosting issue.

UPDATE: I am in the process of moving from 1&1 Hosting to HostMoster. 1&1 runs a PHP as CGI and runs PHP4 instead of PHP5 (you can make a custom .htaccess file to make it run PHP5). I will update you later.

  • 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-05-14T00:10:05+00:00Added an answer on May 14, 2026 at 12:10 am

    The first would be because it’s not a connection, and the second would be because it’s not a query result because it wasn’t a connection. Use mysql_error() to figure out what went wrong in the connection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result I have
Check this code: $select = mysql_query(SELECT * FROM nieuws ORDER BY id DESC LIMIT
This is my php code (I already have a connection to the db): $result
Can i get the source code for a WAMP stack installer somewhere? Any help
I need to solve the following question which i can't get to work by
$query = mysql_query(SELECT * FROM news WHERE id = '{$_GET['id']}'); $news = mysql_fetch_assoc($query); $sql84
function get_total_adults() { $sql = SELECT SUM(number_adults_attending) as number_of_adults FROM is_nfo_rsvp; $result = mysql_query($sql)
Can I use a query in MSSQL to get the .mdf and .ldf filename/location
I'm just trying to get MySQL to store time in GMT... I've read the
I get a mysql error: #update (ActiveRecord::StatementInvalid) Mysql::Error: #HY000Got error 139 from storage engine:

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.