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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:30:20+00:00 2026-05-24T06:30:20+00:00

Here is my code: //Connect to config file include(dirname(__FILE__)./../config.php); //Connect to the database $db

  • 0

Here is my code:

//Connect to config file
include(dirname(__FILE__)."/../config.php");
//Connect to the database
$db = mysql_connect("$dbHost", "$dbUser", "$dbPass") or die ("Error connecting to database.");
mysql_select_db("$dbDatabase", $db) or die ("Couldn't select the database.");

//Get Total Products
$result = mysql_query("SELECT * FROM $dbProductsTable WHERE sub_cat = '$subcat'");
$TotalProducts = mysql_num_rows($result);

//Create Pages
if (TotalProducts <= 12){
    $pages = '';
}else{
    $pages = "                  <ul id=\"pagination\" class=\"group\">
                        <li><a class=\"current\" href=\"#\">1</a></li>
                        <li><a href=\"#\">2</a></li>
                        <li><a href=\"#\">3</a></li>
                        <li><a href=\"#\">4</a></li>
                    </ul>";
}




//Get from sql info we need
$sql = mysql_query("SELECT * FROM $dbProductsTable WHERE sub_cat = '$subcat' LIMIT 0 , 12");
$data = mysql_query($sql) or die(mysql_error());

//Make first letter UpperCase
$subcatname = ucfirst($subcat);
//Get Basket Count
$basketcount = count($_COOKIE['products']);

//Get All Products
while($row = mysql_fetch_array($data))
{
//Get Product Path
$productPath = $Domain.'/'.strtolower($row['category']).'/'.str_replace(" ","",$row['product_name']).'_'.$row['product_id'];

//Build Products List
$products = $products."     <li class=\"all-products-list-item\">
            <a href=\"$productPath\" title=\"{$row['product_name']}\"><img src=\"$ProductImageFolder{$row['thumb_image']}\" alt=\"{$row['product_name']}\" border=\"0\" height=\"245\" width=\"180\"/></a>
            <h3><a href=\"$productPath\">{$row['product_name']}</a></h3>
            <p>£{$row['price']}</p>
        </li>\n";
}

and here is the error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #6' at line 1

i have tried running it throught phpmyadmin and the sql works perfect, i cant find what the problem is ?

Thanks

  • 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-24T06:30:21+00:00Added an answer on May 24, 2026 at 6:30 am

    Here is the error:

    //Get from sql info we need
    $sql = mysql_query("SELECT * FROM $dbProductsTable WHERE sub_cat = '$subcat' LIMIT 0 , 12");
    $data = mysql_query($sql) or die(mysql_error());
    

    Change it to

    //Get from sql info we need
    $sql = "SELECT * FROM $dbProductsTable WHERE sub_cat = '$subcat' LIMIT 0 , 12";
    $data = mysql_query($sql) or die(mysql_error());
    

    You are running a query with $sql = mysql_query(...), and are assigning the resource to the variable $sql. Right after that, you try to run a query with the variable $sql as a parameter. At this point $sql will contain the resource, not the query.

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

Sidebar

Related Questions

Here the code: <?php include_once 'config.php'; // Connect to database $conn = oci_connect($dbuser, $dbpasswd,
here is the code <?php session_start(); if(!isset($_SESSION['user_name'])) { header('Location: login.php'); } $conn = mysql_connect(localhost,
I need to retrieve values from CakePHP's config file database.php from one of my
i use a file ( ss-config.php ) which contains informations about servor and database
I have created a file name database.php and here is it's content <?php #Start
Here's my code <?php $host = 'localhost'; $username = 'sam_sam'; $password = '[censored]'; $name
Here's the one I'm using: <?php final class Database { private static $oDb; public
my database config has changed so Magento is not able to connect anymore. The
enter code here Hi All, I have a simple windows service application that connects
Ok the error is showing up somewhere in this here code if($error==false) { $query

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.