mysql

Display MySQL BLOB'd image on webpage without separate script (PHP)

So I've got some images stored in a MySQL database as BLOB's (I know it's better to just store the directory and do it that way, but this is what I need to do for now) and I need to display them on a webpage. Now, I know how to make a script and give it an image header and pull the img src from there, but I have a lot of images from diff...

Update last child id in parent table using mysql

Given the following tables: Topic id, last_updated_child_id Response id, topic_id, updated_at How do I update the Topic table so the last_updated_child_id is equal to the latest response id (based on date). So for example given: Topic id last_updated_child_id -- ----------------------- 1 null 2 null 3 null Respon...

PHP Array in MySQL IN() function?

Is it possible to assign php array in MySQL IN() function? for example, $numbers = array('8001254656','8886953265','88864357445','80021536245'); $sql = mysql_query("SELECT * FROM `number_table` WHERE `number` IN ($numbers)"); Any Ideas? Thanks, ...

how to store data with many categories and many properties efficiently?

We have a large number of data in many categories with many properties, e.g. category 1: Book properties: BookID, BookName, BookType, BookAuthor, BookPrice category 2: Fruit properties: FruitID, FruitName, FruitShape, FruitColor, FruitPrice We have many categories like book and fruit. Obviously we can create many tables for them (M...

Pagination links do not work after first page

Hello, I am trying to fix this pagination script. It seems when I click on the pagination links [1][2][3][4]or[5] , it doesn't work. It just shows the first page and when clicking on the next numbers nothing happens. I hoping someone can see something in the script that I can not see. The main page looks like this (pagination.php): <?p...

is there mysql corelib site for building queries?

Maybe i have the wrong context but... Is there a corelib site for mysql like http://corelib.rubyonrails.org/ for ruby on rails RoR? Would be nice to have 1 stop shop. thx. ...

using mysql system user

What are the possible disadvantages / pitfalls of using linux system user 'mysql' to work with mysql server instead of creating a separate use? ...

How to save Excel date time cell into MySQL using VBA?

The mysql table has a DATETIME field. I want to INSERT a new row into this field using the cell data from the Excel worksheet. But I cannot use the datetime formatted cell value in a INSERT INTO query. How can I implement this? ...

PHP Web Service vs mySQL Connector on Windows Application

I have a Windows Application in C#. This application interacts with a remote mySQL database. Should I create a PHP web service to do these (insert/add/delete/update) or use mySQL connector for c#? I'm not sure which way is better. Thanks! ...

How can I put rows of MySQL data under the appropriate titles using PHP?

I have the following MySQL table structure: num field company phone website 1 Gas abcd 123456789 abcd.com 2 Water efgh 987654321 efgh.com 3 Water ijkl 321654987 ijkl.com 4 Heat mnop 987654321 mnop.com 5 Gas qrst 123789654 qrst.com ... Is it possible with PHP (maybe using some mixture of GROUP_BY and ...

help solve a problem in parsing dmoz rdf files using php script

Hi, I used the php script in http://sourceforge.net/projects/dmoz2mysql/files/ to download , extract , clean , parse and insert dmoz data into mysql table. i encounter no problem while processing structure.rdf . But while parsing content.rdf , there is an abrupt pause after inserting 3200000 rows.. and nothing happens after that - ...

Using php variable inside a query

Hi, i am using a query inside php as $query = 'SELECT * from #__chronoforms_UploadAuthor where text_6 like "%'.$_GET['title'].'%" and text_7 like "%'.$_GET['author'].'%" limit 0,1'; where i am trying to insert a php variable instead of 1 in the limit.. $query = 'SELECT * from #__chronoforms_UploadAuthor where text_6 like "%'.$...

MySQL timestamp and GROUP BY with two tables

I have a table with 3 fields: ID (not unique, not primary key) timestamp marker I want to get the last entry for every distinct ID, but when I doSELECT ID, max(timestamp) from table GROUP BY IDthe marker field is wrong. I have another table with the following fields: ID (unique, primary key) lat lng I would like to perform the s...

Problem in migrating to LAMP from XAMPP.. Memory limit error

I was using XAMPP for my local machine but as I wanted to run applications like mysql work bench and some test frameworks I decided to switch to LAMP self install. I'm using ubuntu and followed the instructions at: https://help.ubuntu.com/community/ApacheMySQLPHP But the problem is LAMP is consuming too much of my memory (RAM) I've allo...

MySQL return 0 if nothing found

$query = "SELECT field1, field2 FROM table WHERE id IN (1, 2, 3, 4, 5)" $result = mysql_query($query); $array = mysql_fetch_assoc($result); If there is no id#3, then $array['field1'][3] returns next result (if any). But I need it to return 0 in that case. So that $array should contain 5 elements, even if not all were in database. I...

How do I select count() and LIMIT?

SELECT * FROM ...LIMIT 5, 10 But what if I want the total rows? I don't want to make another query without the limit. I just want this one query to return the total rows if I didn't put the LIMIT in there. ...

(MySQL) Ignore lines with a starting symbol when importing a file

I have an input file I want to load into a MySQL database, but spread throughout the file are comment lines, which start with !. For example, !dataset_value_type = count The other lines that I want to read into the table are normal, without the leading !. What is the import command to ignore lines that start with !? I just see comma...

Sql Query - stuck with simple left join

Hey guys I've been stuck with this simple Sql query for last 3 hours and my mind is drawing blank. I have a User table that captures name user_id etc Then I have a friends table that captures who is friend of whom and their status User user_id name Friend friend_id user_id user_friend_id status (accepeted,pending etc) What I want ...

How do I execute SQL_CALC_FOUND_ROWS in python MySQLDB

cursor.execute("SELECT SQL_CALC_FOUND_ROWS user_id FROM...limit 5") rows = cursor.fetchall() ... total_rows = cursor.execute("SELECT FOUND_ROWS()") #this doesn't work for some reason. Edit: I tried SELECT FOUND_ROWS() FROM my_table...and the numbers are funky. ...

How to use only 1 query to get the data everyday within one year

Hi all, I want to get the data everyday within one year backward but I have to use 365 queries for each day like: for ($i = 0; $i<365; $i++){ $end_day = ...; // the end time of each day $start_day = ...; // the start time of each day $query = select count(*)....where created < $end_day AND created > $start_day } I think t...