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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:06:55+00:00 2026-05-24T13:06:55+00:00

I am inserting some values into a mysql database, and before I insert I

  • 0

I am inserting some values into a mysql database, and before I insert I want to check if one of the input fields has a value that is already in the database before I allow the insert.

When I run the script I get this error:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

and the error points back to this line in my PHP:

if(mysql_num_rows($result) > 0)

Here is the PHP:

$qry = "SELECT * FROM videos WHERE tape_no='$tape_no'";
$result = $dbLink->query($qry) or die (mysql_error());
if($result) {
if(mysql_num_rows($result) > 0) 
{
echo '<html>';
     echo '<head>';
echo '<link href="/module.css" rel="stylesheet type="text/css" />';
echo '</head>';
echo '<body>';
echo '<h1>Error</h1>';
echo '<h3>The Tape Number That You Have Entered is a Duplicate, Please Choose Another Tape Number</h3>';
echo '<FORM><INPUT TYPE="BUTTON" class="bluebutton" VALUE="Go Back" ONCLICK="history.go(-1)"></FORM>';
echo '</body>';
echo '</html>';
}
@mysql_free_result($result);
}

Does the column that I am referencing need to be of a certain data type (ie. Integer) ? Will a varchar column type work here?

  • 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-24T13:06:56+00:00Added an answer on May 24, 2026 at 1:06 pm

    Introduction

    PHP ships with two distinct MySQL-specific API extensions:

    • MySQL, supporting procedural style only (mysql_query());
    • MySQLi, supporting OO style (mysqli::query()) and procedural style (mysqli_query());

    • There are also vendor-nonspecific abstraction layers, such as PDO.


    Your problem

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

    Well, it’s not one.

    if(mysql_num_rows($result) > 0)
    

    expects that $result is a result resource as obtained through the MySQL series of functions.

    However, in your code, it’s most likely a result from some other extension. Unless you’ve written some leaky abstraction layer, you’re mixing two different extensions!

    (You’re going to have the same problem with mysql_free_result($result). Read the documentation for whichever extension you’re using.)


    Your solution

    If using MySQLi, try:

    if ($result->num_rows > 0)
    

    If using PDO, try:

    if ($result->rowCount > 0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get some strange behavior when inserting values into a map: I always insert
I'm inserting some HTML into a MySQL database table. But when I get it
dear All. I'm using integer PKs in some tables of mysql database. Before input
When inserting a row in mysql database, string values need to be enclosed in
I am having some trouble inserting an array into the sql database. my error
I am using this code to insert some values in MySql table: <?php mysql_connect(localhost,root,root);
Hey guys, im trying to insert some checkboxes into a database and im pretty
I am inserting values in to Database from a Webform using ADO.NET, C#. DB
I am wanting to insert a datetime into a MySql data base using Java
i am inserting values into a table if the record exists already replace it,

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.