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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:39:14+00:00 2026-05-23T13:39:14+00:00

Been very frustrating but mysql is returning an empty set for this code (not

  • 0

Been very frustrating but mysql is returning an empty set for this code (not echoing exists) :

if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  mysql_select_db("repository", $con);

$url = stripslashes($url);
$url = mysql_real_escape_string($url, $con); 
$exists = mysql_query("SELECT url FROM sites WHERE url = '$url' LIMIT 1");
 if (mysql_num_rows($exists) == 1) {
    echo "exists";
 } 

it should not be doing this because I’ve tested a good amount.

The table consists of one column “url”, it is datatype varchar(1000) (the maximum). the url stored for test purposes is http://en.wikipedia.org/wiki/Thailand

  • 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-23T13:39:14+00:00Added an answer on May 23, 2026 at 1:39 pm

    Here’s what you do as a first step. Remove the WHERE url = '$url' from your query altogether and print out mysql_num_rows($exists) before using it.

    That should be enough to tell if it’s one of the two likeliest problems:

    • bad URL resulting in no rows being returned; or
    • bad row caused by database containing other than you expect.

    Based on your comments to date, the former is the most likely. If it turns out you get a row back without the where clause, you’ll have to figure out why your URL is incorrect. This may be a case-sensitivity issue or a padding (size) issue, among other things.


    If, as you mention in a comment, like works where = doesn’t, then we need to see your data.

    Execute (at the DB level):

    select concat('[',url,']') from sites
    

    and show us exactly what the output is. Similarly, output the URL being used by the code with something like:

    print_r($url)
    

    immediately before executing the mysql_query.

    Please append the output from both those commands to your question.

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

Sidebar

Related Questions

I have been using Hibernate very successfully, but today I noticed a bizarre phenomenon
I've been using VMWare for a while and am very happy with it, but
Hi I'm very new to sql but have been passed a job in which
This issue has been very hard for me to debug. I am a pc
We use Perl for GUI test automation. It has been very successful. We have
I have always been a very big fan of the DHTML calendar http://www.dynarch.com/projects/calendar/ I
I've been experiencing very inconsistent results while developing an iPhone app and trying to
I have been noticing some very strange usage of O(1) in discussion of algorithms
I've been working on a very simple crud generator for pylons. I came up
I have recently been working with someone on a project that is very ajax

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.