mysql

PHP App (ExpressionEngine) slow to load on IIS 7, MySQL, FastCGI

I'm working on debugging a slowness issue I've got with running ExpressionEngine (a PHP application) on IIS 7. I don't think this is actually an issue with ExpressionEngine, but rather an issue with my PHP/MySQL setup. The problem shows itself thusly: Go to webite address IE "spins" for 10-15 seconds, waiting to load. During this ti...

Determine Which Part(s) of WHERE Statement Failed

Let's say I have a SQL statement like this that checks a user login: SELECT * FROM users WHERE username='[email protected]', password='abc123', expire_date>=NOW(); Is there a way in SQL to determine specifically which WHERE conditions fail, without having to separate each condition into its own query and test individually? In this sp...

SQL: COUNT() with items appearing multiple times in one-to-many relationship? Alternative to GROUP BY?

I have a query listing product categories, by supercategory > category. The query counts the number of products in each category (COUNT(ptc.catid)). Howewer: the query doesn't let a category appear twice (a category can be linked to multiple supercategories). How can this be re-written so categories (c.title) can be listed under multip...

Cannot log in with created user in mysql

Using this command GRANT ALL PRIVILEGES ON *.* to 'brian'@'%' identified by 'password'; I try to login with: mysql -u brian -ppassword The error is: ERROR 1045 (28000): Access denied for user 'brian'@'localhost' (using password: YES) I am doing this as root and I did try to flush privileges. I tried this with countless users b...

Code Addition is Slowing Page Down

My client ordered another addition to the script, but I can't figure out how to fix the slowdown? The table has about 50,000 rows. while($stats = mysql_fetch_array($get_stats)) { if ($stats['ip'] == gethostbyaddr($stats['ip'])) { // new code $is_undef = "Yes"; // causing problems } else { $is_undef = "No"; } // e...

Selecting a single row in MySQL

I have a table that has nine columns in it. one of them is the primary key. How can I select a single row, and all of the columns in it, by the primary key or column 8 or 4? I'm using PHP and MySQL ...

How to implement cascading deletion of hierarchical data in MySQL?

Hi, I'm working on a project that has categories / subcategories. The database table for this is unique, with the following structure : CREATE TABLE IF NOT EXISTS `categories` ( `id` int(11) NOT NULL auto_increment, `publish` tinyint(1) NOT NULL default '0', `parent_id` int(11) NOT NULL default '0', `description` text NOT NULL,...

python mysql fetch query

def dispcar ( self, reg ): print ("The car information for '%s' is: "), (reg) numrows = int(self.dbc.rowcount) #get the count of total rows self.dbc.execute("select * from car where reg='%s'") %(reg) for x in range(0, numrows): car_info = self.dbc.fetchone() print row[0], "-->", row[1] the ab...

Tricky SQL statement over 3 tables

I have 3 different transaction tables, which look very similar, but have slight differences. This comes from the fact that there are 3 different transaction types; depending on the transaction types the columns change, so to get them in 3NF I need to have them in separate tables (right?). As an example: t1: date,user,amount t2: date,us...

phpMyAdmin: change default number of rows displayed?

By default, phpMyAdmin shows me 30 rows whenever I load a table (the query contains "LIMIT 30"). I generally want to see (up to) a few hundred rows. Is there a way to change that default setting? ...

Basic SQL Injections?

I was told in a previous question that my query is prone to SQL injections. get_stats = mysql_query("SELECT * FROM visitors WHERE site='$_GET[site]' AND date BETWEEN '$start_date' AND '$end_date' "); What would be the easiest way to approac...

Wordpress and MySQL Collations

Hi Folks. I'm just having this trouble with Wordpress: I use to have a Blog with and older version of it and of MySQL, and when I export the SQL DB Creation Scripts, they exported with the latin1_swedish_ci Collation. Know I'm trying to rebuild the blog but it shows a lot of strange characters like: Imaginaré Creativitá When It mu...

How to log/pinpoint which PHP script uses a lot of memory? Optimization Question

Hello, I wrote a small app that turns out to be using a lot of memory when used by a few users simultaniously. This is leading to some Fatal PHP errors and some mySQL (errcode 12) errors. My Plesk QoS page shows frequent 'kmemsize' black zone errors. My question is: What's the best method to monitor PHP script runs to pin-point which ...

getting all values from three different tables .. JOIN problem?

I'm learning mysql and have been trying to get this working, but an error always comes up no matter how I try it - or it just doesn't show anything from the table. I have 3 tables, all with the same amount of columns and name of columns I want to list all the values in alphabetical order by title Tables: General - Temp - Location Col...

SQL SELECT order by 2 columns and group by

Here're the RS return and the sql issued, SELECT *, (UNIX_TIMESTAMP(end_time) - UNIX_TIMESTAMP(start_time)) AS T FROM games WHERE game_status > 10 ORDER BY status, T; game_id, player_id, start_time, end_time, score, game_status, is_enabled, T 65, 22, '2009-09-11 17:50:35', '2009-09-11 18:03:07', 17, 11, 1, 752 73, 18, '2009-09-11 18...

Inserting raw (binary?) image data into mysql? (PHP)

I've got a raw/(binary?) image like this: ÿØÿà�JFIF��–�–�*!!!$'$ &(goes on forever); when i try to insert this into mysql it doesn't work, the column type is set to longblob, any ideas? ...

PHP/MYSQL grab data from of all matching fields

What is the propper syntax to grab data from of all the matching fields? This example outputs only 1 of the matching fields: $myvariable = "SELECT post_content FROM wp_posts WHERE post_name = 'testing' AND post_status = 'publish' AND post_type = 'post'"; echo = $...

MySQL perform several queries with OR

Can someone please help me with how I can add several different queries to one query with OR? I have posts that I only want to show to user that are allowed to see it OR groups that are allowed to see it OR every on. SELECT p.*, c.name, cb.categoryId FROM Posts AS p LEFT JOIN CategoryBindings AS cb ON cb.postId = p.id LEFT JOIN Categor...

CREATE TABLE AS SELECT killing MySQL

We run a MySQL server with moderate load (200-300 QPS) on quite powerful hardware (HP DL360 with 8 Xeon cores, 8Gb RAM and RAID10). All the tables are innodb and the active dataset fits within the allocated innodb_buffer_pool_size. Our database is normalized and to reduce the number of joins we use materialized views to flatten the data...

PageRank in a inner search engine of a CMS

Hi to everyone. I was asked for my final degree project to build a custom SEO Content Management System; the point is that the request is to implement PageRank alghoritm for the inner search engine of this CMS, to order the results of the query by the PR. Is it possible? How may I start with this? The CMS is build on PHP and MySql (or P...