Skip to content

Tag: mysql

Using isset() inside a foreach doesn’t work?

Basically, I have an indefinite number of buttons that I want to generate from variables held in the mysql database. Now when I try to press the buttons nothing happens. This is the code I thought might work for that: There are no errors. I think it’s because I can’t use isset inside a foreach thi…

How to create a custom JSON layout from MySQL in PHP

I have a MySQL query in PHP that pulls back two columns of results Column One is Label Column Two is Value I have read http://nitschinger.at/Handling-JSON-like-a-boss-in-PHP but im struggling to understand how I can do the following JSON in PHP from MySQL I can manually write a loop to output the raw text to …

PDO fetch / fetchAll

Not new to PHP, but only a day old to PDO. Surely I am doing something wrong here. the only way I can declare those $_SESSIONS properly is if I use $result[0][‘fieldName’]; How can I just access it via $result[‘fieldName’]; ? Answer fetchAll, as the documentation says, retrieves an arr…

Undefined function mysql_connect()

I have ran aptitude install php5-mysql (and restarted MySQL/Apache 2), but I am still getting this error: Fatal error: Call to undefined function mysql_connect() in /home/validate.php on line 21 phpinfo() says the /etc/php5/apache2/conf.d/pdo_mysql.ini file has been parsed. Answer Well, this is your chance! I…

Database Driver MySQLi Error

I am running Moodle test environment on Window Vista having PHP 5.2.10 and MySQL 5.1.36-Community. When I upgrade from Moodle 1.9.9 to 2.0, I am getting the following error. I also tried to change the dbtype=’mysqli’ in config.ini and still see same error. I would really appreciate if you can prov…

PHP MySQL Insert Ignore Inserting Too Much Data

I have a traffic exchange and every time a site is viewed I want it to insert in to a table which looks like: -user -site The user is default of 1 and I don’t insert in to it because I thought for an INSERT IGNORE you need a column that stays in the same. My current query: I have