mysql

Zip HTML/PDF, store as Blob

I have a variable which contains the html content, $html and a variable with the pdf content $pdf. I can create zip files by using $zip->addFile($file,$file); where $file is a file on the disk However, I want to create zip files with content from the variables, without having to write them to disk first. How do I do it? I am already s...

second last row of a table mysql

I was playing in a MySQL database and wanted to only view the record that had second to last of table but did not get any row the query is given below What is the problem of my query SELECT * FROM table WHERE id='(LAST_INSERT_ID()-1)' ...

Getting Javascript to talk to PHP

On my page I have a table, and this table has a list of items plus an edit button. When the edit button is clicked, I want to fill the form with the information specific to that entry in the table. All the information is stored in a mySQL database and can be accessed by PHP. I need my javascript on the edit button to get the table row ...

Is it possible, to calculate the number of matches in mysql like structure?

Lets assume i have a query like the following $query_search = "SELECT * FROM `search` WHERE `title` LIKE '%$word%' OR `content` LIKE '%$word%'"; i need to order rows by count of matches? is it possible in such structure of database, or i need to redesign it? Thanks much ...

Script restarts executing after a while

Hi, I'm busy with a project in cakePHP where I need to parse a couple of XML files and insert the relevant data in my mysql database. The script inserts what it should insert, that's not the problem. For example if I parse one or 2 files (approx 7000-8000 records), nothing goes wrong. Problems start when I parse the third or fourth xml...

Float type in MySQL

I have a MySQL table with column of type float(10, 6). If I insert 30.064742 into the column the value stored in the database is 30.064741. Why? ...

Parsing a Separate PHP Array in Javascript

So, as sort of an exercise in learning, I am trying to port a site I was working on for someone, written in PHP, MySQL and CSS, over to Ajax (Specifically, really, just adding Javascript so that the page is dynamic instead of needing to constantly reload). Unfortunately, I have some scripts I'd like to keep as PHP (for instance, a scrip...

php DBAL for MySQLi/MSSQL row fetching

I'm trying to write a simple, thin and efficient database abstraction layer on top of the PHP MySQLi (procedural) and MSSQL libraries, to be used like this... while ($a = db::go('db_name')->query('select * from foo')->row()) { print_r($a); } I have the class written, but am struggling somewhat with how best to loop through the resul...

Multi SQL Queries in associative array with PHP/SQL

I've got a very simple question about sending multi-queries with php/sql and add each result in an associative array. Basically, I've assigned each query in an associative array. Each result for each queries go into my multi-dimensional array $el['nameofthequery']['resultsofthequery'] //connection information $host = "localhost"; $u...

Today, mysql_real_escape_string() is escaping single quotes AND double quotes.

$str = 'BEGIN This is a "quote" test. \'Single\' END'; echo $str . "\n"; echo mysql_real_escape_string($str); // Outputs: BEGIN This is a "quote" test. 'Single' END BEGIN This is a \"quote\" test. \'Single\' END Running PHP 5.3.2 on CentOS. As far as I can remember, mysql_real_escape_string() will only escape single quotes to prevent ...

MySQL: Split column into two...

I have a table with rows like this: | Country.Number | Country | | US.01 | USA | | US.02 | USA | I'd like to modify this to: | Country | Number | Country | | US | 01 | USA | | US | 02 | USA | Is there an easy way to do this? ...

Search for records with apostrophe

I am trying to search the database for a keyword like Obrien and the results should return all the records with O'Brien too. I have tried with fulltext search of MySql. The problem with it is the resultset can cntainn only 1 record but fulltext feature requires the resultset to contain atlest 3 records or 50% of the matched results. Do...

MySQL Triggers insert into another table

Hello, Syntax-wise , what's wrong with the following query : -- Trigger DDL Statements DELIMITER $$ USE mydb$$ DROP TRIGGER IF EXISTS annual_scenario; CREATE TRIGGER annual_scenario AFTER INSERT ON quote FOR EACH ROW BEGIN SET @annual_date = (SELECT NEW.date - INTERVAL 1 YEAR); SET @annual = (SELECT COUNT(DISTINCT Q.date) ...

MySQL row number

Hi, say I have a MySQL query, for example SELECT id, name, surname FROM employees ORDER BY id the result woud be id name surname 1 Peter Smith 2 John Banjo ... 1384 Will Levenstein While this is an ordered query, I can always assume (as long as I don't change the table) that John Banjo will come out second...

MySQL Multi-Insert? MySQL DB integrity after failed INSERT

Is it possible to insert a row into multiple tables at once? If you do several tables related by an ID; what is the best way to ensure integrity is maintained in case an INSERT fails? ...

How to group by month+year?

http://www.bioshapebenefits.nl/bioshapebenefits/en/news/donations.html As you see, here I have a long list of entries, sorted by date, very simple. So in mysql there would only be the columns 'name' and 'date', for example. And if I'd want to make a list out of it with php that would also be very simple, just sorting by date. But how w...

MySQL BIT vs SET

Does anyone know where in the MySQL literature the reference is made to merging BIT fields? I am having a hard time locating any documentation that distinguishes SET from BIT. ...

MySQL query results used in LIKE

I am trying to write a query to pull all the rows that contain a username from a large list of usernames in a field. For example, the table contains a column called 'Worklog' which contains comments made by users and their username. I need to search that field for all user names that are contained in a list I have. I have tried a few d...

MySQL Optimization, "like" vs "="

I have a table with columns like this: | Country.Number | CountryName | | US.01 | USA | | US.02 | USA | I'd like to modify this to: | Country | Number | CountryName | | US | 01 | USA | | US | 02 | USA | Regarding optimization, is there a difference in performance if I use: select...

Outlook CSV to MySQL PHP Class

I was wondering if anyone has come across a solid pre-built class for PHP to work with MS Outlook. To have the ability to TAKE a CSV file and import it into a MySQL Database, and also do the reverse export from the database into a solid CSV file to import into Outlook. If someone has come across something like this, could you possibly s...