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

  • Home
  • SEARCH
  • 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 8199757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:14:13+00:00 2026-06-07T06:14:13+00:00

My PHP functions script was working fine last night, and now when I logged

  • 0

My PHP functions script was working fine last night, and now when I logged on to work on it some more today, I am getting

"Warning: mysql_result() expects parameter 1 to be resource, boolean given".

I have -no- idea why this isn’t working. I’ve read the PHP manual online, and I’ve even seen examples where what I did is used and works. Can anyone please help me out with this? I’ve been fixing bug after bug (so many things stopped working when I logged on today) and I’m at my wits end here. If it helps, I’m using XAMPP on Windows 7 for my server.

Code: (also available via Pastebin)

<?php

function dbConnect() {
$dbserver="127.0.0.1";
$dbuser="Mike";
$dbpassword="mike";
$dbname="devsite";

$con = mysql_connect($dbserver, $dbuser, $dbpassword);
mysql_select_db($dbname, $con);
}

function getSiteTitle() {


$siteTitle = mysql_result(mysql_query("SELECT \`siteTitle\` FROM siteSettings"), 0);
return $siteTitle;
}

function getSiteHeader(){

$siteHeader = mysql_result(mysql_query("SELECT \`siteHeader\` FROM siteSettings"), 0);
return $siteHeader;
}

function getBodyContent() {


$bodyContent = mysql_result(mysql_query("SELECT \`bodyContent\` FROM siteSettings"), 0);
return $bodyContent;
}

?>
  • 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-07T06:14:15+00:00Added an answer on June 7, 2026 at 6:14 am

    The problem is that mysql_query() is returning a boolean instead of a result resource. There are two reasons this can happen:

    1. You performed query that returns success/fail instead of a result set (e.g. UPDATE)
    2. Your query failed

    In your case the query failed. The reason it failed is because you have escaped the back ticks in the PHP string where you did not need to.

    Your lines look like this:

    $siteTitle = mysql_result(mysql_query("SELECT \`siteTitle\` FROM siteSettings"), 0);
    

    When they should simply be this:

    $siteTitle = mysql_result(mysql_query("SELECT `siteTitle` FROM siteSettings"), 0);
    

    Now, some side notes:

    • Don’t write new code that uses the mysql_* functions. They are deprecated and will eventually be removed from PHP. Use MySQLi or PDO instead (I personally recommend PDO, YMMV)
    • Nesting database functions in this way is not a particularly good way to write your code. It is much better to check the errors explicitly after every function call.

    For example:

    $result = mysql_query("SELECT somecol FROM sometable");
    if (!$result) {
      // Handle error here
    }
    // Now process the result
    
    • You should quote either all identifiers, or none, in your queries (preferably all). Quoting only some makes it harder to read.

    E.g.

    SELECT `siteTitle` FROM `siteSettings`
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a script for looping thru PHP files and renaming function calls
I am currently re-writing my functions script (PHP) for my login system. Is the
The script below resides in my theme's functions.php file. It is designed to show
I'm using tokenInput jquery plugin for autocomplete. This script is working fine <script type=text/javascript>
I'm using Shared Linux hosting and some PHP I wrote just won't work with
The script below is working fine with Firefox and Chrome but I cant seem
I have a jquery script that is working fine except being able to send
learning Jquery and integrating with PHP - getting there, but have one last challenge
Okay, so I have this script which works fine with IE but won't work
I am using a PHP script using dns_get_record (with DNS_ANY) and it is working

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.