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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:01:57+00:00 2026-06-13T23:01:57+00:00

Editing someone else’s code here, so I can’t change the field in the database

  • 0

Editing someone else’s code here, so I can’t change the field in the database called title or change to MySQLi etc :/

The code connects to the DB without problems, but always pulls in zero results.

$strSQL = "SELECT * FROM newproducts WHERE 'title' LIKE ('%$q%')";
$sql = mysql_query($strSQL) or die(mysql_error());
$num_rows = mysql_num_rows($sql);

if ( $q == '' ) {
    echo '<p class="black-text">Please provide a search term.</p>';
}

else if ( $num_rows <= 0 ) {
    echo '<p class="black-text">Your search for <b>'.$q.'</b> returned <b>0</b> results.</p>';
}

else { 

    echo '<p class="black-text">Your search for <b>'.$q.'</b> returned <b>'.$num_rows.'</b> result(s).<br/><br/>';  
    while($row = mysql_fetch_assoc($sql)) {
        echo '- '.$row['title'].' <a href="'.$row['link'].'.html" class="search-link">[Read more]</a><br/>';
    }
    echo '</p>';
}

Could it be a case issue? I’ve tried searching for lower and upper strings, but still zero results.

  • 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-13T23:01:58+00:00Added an answer on June 13, 2026 at 11:01 pm

    In MySQL single quotes denote strings:

    SELECT * FROM newproducts WHERE 'title' LIKE ('%$q%')
    

    Should be

    SELECT * FROM newproducts WHERE title LIKE ('%$q%')
    

    Additionally, you are testing for if ($q == '') after you have performed the query – you may want to do that before – but that isn’t causing your issue.

    And lastly, you are at risk of SQL injection by using potentially unsafe user input – but I’m not going to delve into that as it isn’t directly related to your question. Most PHP developers are using prepared statements these days to make their queries safer (and because the old style of running queries is going to be deprecated).

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

Sidebar

Related Questions

I'm editing some old sideshow code someone else written a while ago and I
I've been editing someone else's code for a project, and I stumble every now
I'm editing a program called TF2idle that can be seen here: http://facepunch.com/showthread.php?t=1161862 I'm adding
Editing this code here on Stackoverflow and I'm really near to get the result
I am editing someone else's PHP, and they have an 'authentication' system in which
I was editing the default code from W3Schools, and it doesn't work now. Can
I'm new to Wordpress plugins, and editing someone else's to add functionality. I need
I'm working on someone else's code where they're building a TcxGrid without going through
I am new to VBA and building off of someone else's code, who was
Can someone check my code? I am having my calculation for the score using

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.