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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:17:20+00:00 2026-06-18T10:17:20+00:00

So i’m working on a project and i am running to to a few

  • 0

So i’m working on a project and i am running to to a few mysql & php errors.

First Error :

This is all code associated with First Error

// Database Class 

class Database {
    public $_link, $_result, $_numRows;

    public function __construct($server, $username, $password, $db){
        $this->_link = mysql_connect($server, $username, $password) or die('Cannot Execute:'. mysql_error());
        mysql_select_db($db, $this->_link);
    }

    public function disconnect(){
        mysql_close($this->_link);
    }

    public function query($sql){
        $this->_result  = mysql_query($sql, $this->_link) or die('Cannot Execute:'. mysql_error());
        $this->_numRows = mysql_num_rows($this->_result);
    }

    public function numRows() {
        return $this->_numRows;
    }

    public function rows(){
        $rows = array();
        for($x = 0; $x < $this->numRows(); $x++) {
            $rows[] = mysql_fetch_assoc($this->_result);    
        }
        return $rows;
    }

}

// Setup.php 

$is_set = 'false'; 
global $company_name, $ebay_id;
    if( isset($_POST['ebay_id'], $_POST['company_name']) ){
        $_ebay_id = $_POST['ebay_id'];
        $_company_name = $_POST['company_name'];
        $is_set = 'true';
    } else { 
        // Silence is Golden!
    }

    $_service_database = new Database('localhost', 'root', 'password', 'chat-admin');

    $_service_database->query("SELECT * FROM installs WHERE `identity` = '$mysqldb' AND `db_name` = '$mysqldb'");


    if ($_service_database->numRows() == 0){ 
        if($is_set == true){
             $_service_database->query("INSERT INTO installs (ebay_id, name, db_name, identity) VALUES ('$_ebay_id', '$_company_name', '$mysqldb', '$mysqldb')");
        } 
    } else { 
        // header("Location: index.php");
    }
    $_service_database->disconnect();

?>

<form name="setup" method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
<input placeholder="eBay Username" type="text" name="ebay_id">
<input placeholder="Company Name" type="text" name="company_name">
<input type="hidden" name="insert" value="true">
<input type="submit">
</form>

So what this does is checks if the variables defined are in the database if they are not then when the form is submitted it inserts our values, if they are in the database it redirects to index.php, ok so i am receiving the all mighty MySQL num_rows* expects parameter 1 to be resource, boolean given …, now i have searched everywhere and only found that the die error should solve, that is why you can see it on line 16 in the function query, now although i get the error everything still works its not really good for me to turn error reporting off so any help would be great. Also if you see undefined variables like $mysqldb they are actually set but on a different page and they are valid

Second Error : = function made for simplicity of a templating system

This is all associated with Second Error

function get_content_type($value){
    if (strpos($value,'title:') === 0 ) {
        $title = explode("title: ",$value);
        $value = $title[1];
    } else if (strpos($value,'css:') === 0 ) {
        $css = explode("css: ",$value);
        $value = $css[1];
    } else if (strpos($value, 'js:') === 0 ) {
        $javascript = explode("js: ", $value);
        $value = $javascript[1];
    } else {
        // Silence is Golden
    }

    if($value == $title[1]){
        echo '<title>'.$value.'</title>';
    } else if ($value == $css[1]) {
        echo '<link rel="stylesheet" href="'.$value.'">';
    } else if ($value == $javascript[1]) { 
        echo '<script src="'.$value.'"></script>';
    }
}

// Calling
get_content_type('title: Welcome to my site');
get_content_type('css: http://something.com/style.css');
get_content_type('js: http://code.jquery.com/jquery-latest.min.js');

everything works as this outputs

<title>Welcome to my site</title><link rel="stylesheet" href="http://somesite.com/style.css"><script src="http://code.jquery.com/jquery-latest.min.js"></script>

Only when i set error_reporting(0);

The errors i get are undefined variables because obviously i’m setting one, then im unsettling that one and setting the other so eventually only 1 is true although its already outputted all of them correctly.

UPDATE

Second Error : Errors =

Notice: Undefined variable: css in C:\Server\www\hidie\libs\test.php on line 19
Notice: Undefined variable: title in C:\Server\www\hidie\libs\test.php on line 17
Notice: Undefined variable: title in C:\Server\www\hidie\libs\test.php on line 17

First Error : Errors =

ERROR: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given

  • 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-18T10:17:21+00:00Added an answer on June 18, 2026 at 10:17 am

    Ok so here’s your problem:

    First, as mentioned in the comment, mysql_num_rows only works on select and show. You have it in your query method, which is called by an insert. You can’t do that.

    public function query($sql){
        $this->_result  = mysql_query($sql, $this->_link) or die('Cannot Execute:'. mysql_error());
        $this->_numRows = mysql_num_rows($this->_result); // <- BAD!
    }
    

    You call it on this line:

    if($is_set == true){
         $_service_database->query("INSERT INTO installs (ebay_id, name, db_name, identity) VALUES ('$_ebay_id', '$_company_name', '$mysqldb', '$mysqldb')");
    } 
    

    You could make a second method for database and call it for all calls that write to the db:

    public function execute($sql){
            $this->_result  = mysql_query($sql, $this->_link) or die('Cannot Execute:'. mysql_error());
        }
    

    which would be called like so:

    if($is_set == true){
         $_service_database->execute("INSERT INTO installs (ebay_id, name, db_name, identity) VALUES ('$_ebay_id', '$_company_name', '$mysqldb', '$mysqldb')");
    } 
    

    Second, you need to implicitly define the variables $css and $title outside of those conditionals. Otherwise you are attempting to call undefined vars as indicated by the message…

    $title = "";
    $css = "";
    
    if (strpos($value,'title:') === 0 ) {
        $title = explode("title: ",$value);
        $value = $title[1];
    } else if (strpos($value,'css:') === 0 ) {
        $css = explode("css: ",$value);
        $value = $css[1];
    } else if (strpos($value, 'js:') === 0 ) {
        $javascript = explode("js: ", $value);
        $value = $javascript[1];
    }   else {
        // Silence is Golden
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

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.