Check the manual for mysql_fetch_object()
. It returns an object, not an array of objects.
I’m guessing you want something like this
$results = mysql_query("SELECT * FROM sidemenu WHERE `menu_id`='".$menu."' ORDER BY `id` ASC LIMIT 1", $con); $sidemenus = array(); while ($sidemenu = mysql_fetch_object($results)) { $sidemenus[] = $sidemenu; }
Might I suggest you have a look at PDO. PDOStatement::fetchAll(PDO::FETCH_OBJ)
does what you assumed mysql_fetch_object()
to do
Related Posts:
- Difference between “as $key => $value” and “as $value” in PHP foreach
- How to log in to phpMyAdmin with WAMP, what is the username and password?
- Should I use mysqli_real_escape string() or mysql_real_escape_string() for form data?
- Fatal error: Call to undefined function mysql_connect()
- PDOException SQLSTATE[HY000] [2002] No such file or directory
- http://localhost:80 is not working on running Apache server through UniServer ZeroXIII
- PDOException SQLSTATE[HY000] [2002] No such file or directory
- Mysql query- How to use contains?
- mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in
- Invalid column count in CSV input on line 1 Error
- Invalid column count in CSV input on line 1 Error
- $wpdb->update or $wpdb->insert results in slashes being added in front of quotes
- PDO with INSERT INTO through prepared statements
- phpMyAdmin: secret passphrase?
- Invalid argument supplied for foreach()
- PDO bindParam() with prepared statement isn’t working
- break out of if and foreach
- Forbidden :You don’t have permission to access /phpmyadmin on this server
- Creating a search form in PHP to search a database?
- How can I do ‘insert if not exists’ in MySQL?
- Fatal error: Call to a member function bind_param() on boolean [duplicate]
- Sort array of objects by object fields
- MySqli Commands out of sync; you can’t run this command now
- Fix Access denied for user ‘root’@’localhost’ for phpMyAdmin
- Getting connection failed: php_network_getaddresses: getaddrinfo failed: Name or service not known
- Commands out of sync; you can’t run this command now
- Lost connection to MySQL server at ‘reading initial communication packet’, system error: 0
- PHP with MySQL 8.0+ error: The server requested authentication method unknown to the client
- SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
- How can I do ‘insert if not exists’ in MySQL?
- Trying to get property of non-object – Laravel 5
- Object of class DateTime could not be converted to string
- What does it mean to escape a string?
- Convert from MySQL datetime to another format with PHP
- MAMP “Apache couldn’t be started because port is in use.” AND “Can’t connect to local MySQL server through /tmp/mysql.sock
- mysqli::query(): Couldn’t fetch mysqli
- Unexpected Exception: SQLSTATE[HY000] [1045] Access denied for user ****@’localhost’ (using password: YES)
- php foreach with multidimensional array
- Uncaught Error: Call to undefined function mysql_escape_string()
- Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in
- Call to a member function on null?
- SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens on line 102
- Warning: mysqli_query() expects parameter 1 to be mysqli, resource given
- MySQL query to get column names?
- What does MYSQLI_NUM mean and do?
- Mysql where id is in array
- ERROR: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it
- What is the advantage of using try {} catch {} versus if {} else {}
- select * from table where column = value ^ column2= value
- Deprecated: mysql_query() [duplicate]
- Array of PHP Objects
- No query results for model [App\Products] Laravel
- Fatal error: Call to a member function query() on null
- mysqlworkbench giving version error on exporting database
- How to make DROP INDEX IF EXISTS for mysql?
- What is the meaning of sprintf(): Too few arguments
- Having a problem getting mysqli_query to execute
- CodeIgniter: Unable to connect to your database server using the provided settings Error Message
- Can I store images in MySQL
- MySQL Daemon Failed to Start – centos 6
- How to insert TIMESTAMP into my MySQL table?
- How to remove index.php from WordPress site URL
- PHP Like thing similar to MySQL Like, for if statement?
- How get value from URL
- Object of class stdClass could not be converted to string
- Find the last element of an array while using a foreach loop in PHP
- How to use Memcached with PHP7?
- select count(*) from table of mysql in php
- 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 ””)’ at line 2
- How do I redirect a page in jQuery?
- What’s the purpose of ini_set() in php? (especially for error reporting)
- Send email with PHP from html form on submit with the same script
- Finding the number of days between two dates
- PHP get domain name
- How to solve “Fatal error: Class ‘MySQLi’ not found”?
- Running a Python script from PHP
- HTTP Error 411, The request must be chunked or have a content length
- PHP $_POST not working?
- Laravel – Model Class not found
- Fatal error: Call to a member function fetch_assoc() on a non-object
- Strict Standards: Only variables should be assigned by reference PHP 5.4
- Steam Market API?
- Get JSON object from URL
- How to push both value and key into PHP array
- Transaction when using WP functions rather than vanilla SQL?
- How to merge local and live databases?
- WordPress 3 – how are passwords stored and how do I compare to them?
- How to select WooCommerce products by post_meta and order them
- Remove one value in dismissed_wp_pointers?
- How can I save unique user data on my site? [closed]
- Assign External Database Queries to Global Variables and Make Them Accessible
- Using custom tables for old posts
- Location of core code for database connection and get_header
- WordPress and MySQL: trying to print data using PHP from user_meta custom field data
- Hide posts if user is added to it WP_query
- Get the id of the row from database on click of a button [closed]
- Inside Array – “unidentified index” error with “prepare was called incorrectly” despite not calling the prepared statement with wordpress [closed]
- What is the correct way to search 3 custom fields only in WordPress?
- Query doesn’t display text data with apostrophes
- I want show only data for today