mysql

Is mysql_num_rows efficient and/or standard practice?

A while ago I was poking around with SQLite, trying to port some of my sites to use it instead of MySQL. I got hung up on the lack of a function to count results, like PHP's mysql_num_rows(). After searching a little I discovered this mail list, which says (as I understand it) that SQLite doesn't have that functionality because it's inef...

How to print the Text data type in mysql

A Table has Field: data Type: text select data from t1 where id = 5 *************************** 1. row *************************** data: 1 row in set (0.00 sec) How to print the exact data from table ? NOTE: the Field data is not empty ...

What are the rules mysql uses for displaying float values?

I'm storing values in a column defined as float. When I read back these values from the database they sometimes differ much more from the original values than I would expect (I know that float doesn't store exact values, please take a look at the example to see what I mean). Here's my test case: drop table if exists float_test; create...

Recording MySQL DELETE statements

We have a MySQL->Oracle ETL using Informatica that works great for all statements except DELETE. Unfortunately, the DELETE makes the record go away such that Informatica never sees it again to remove/expire it in Oracle. How have people gone about recording MySQL DELETE statements? The tables are InnoDB (ACID-compliant) with unique pr...

Jquery Form Validation and Checking the values with Mysql Database through PHP Script

I have a form which has a input textbox and submit button. On submission of the form the textbox value should get pass to an php script and check the values whether it exists in the Mysql Database. If it exists then we need to show an alert box stating that "Entered Value is already exists, Try something new". If the value not exists th...

Optimizing ORDER BY Query on large table MySQL

I have a browse category query that im trying to optimize. Im ending up with Using temporary; Using filesort in the explain and the query is slow on a category with say 60,000 rows. If i remove the Order By clauses the query runs very fast .05 seconds to do 60,000 rows. With the Order By clauses its very slow around 5 seconds. Parts cont...

PHP- making a fake directory!

I have been looking at some sites that pretend that there is a directory structure in the URL and wondered 'how?'. I am taking control of a website at work and have looked over the code. They have a database for all the pages and they are created dynamically. I can get the homepage working on my local server but i dont have a clue as...

Woot-badge like in PHP

Hi everyone! Does anybody knows how to implement something into a website written in PHP, similar to the Woot-badge and the Fanatic-badge on stack overflow? I want to reward my users if they visit my site everyday for 75 days, without days they don't visit it. My site uses sessions for log ins. And I use a MySQL database. The users tab...

PHP App doesn't work after migrating to a Windows machine

Hello; A PHP application that was working perfectly on a LAMP server can't require or include files at all after migrating to a Windows Server 2003 machine. For example, given the following file : include("connectme.php"); echo "==== $SERVER_NAME, $USER, $PASSWORD"; $sql="SELECT id, model FROM `products` WHERE acc_code IS NULL O...

How do I filter using parameters but keep NULLs?

I want to be able to pass in a list of parameters, and ignore the ones which are NULL. So that the query is in effect pretending that the filter isn't there and ignoring it. My problem is that the columns I'm filtering do accept NULLs, but if I use something like this, all the NULL fields are removed. WHERE column = Case WHEN NULL colu...

Optimal MySQL-configuration (my.cnf)

The following is my default production MySQL configuration file (my.cnf) for a pure UTF-8 setup with InnoDB as the default storage engine. [server] bind-address=127.0.0.1 innodb_file_per_table default-character-set=utf8 default-storage-engine=innodb The setup does the following: Binds to localhost:3306 (loopback) instead of the defa...

User actions like social networks facebook,myspace, all big ones

I am working on a social network type site in PHP, I have done this once before and the site outgrew my coding ability to keep up, this was a couple years back and now I am wanting to tackle this project again. Basicly on my network there is a friend_friend mysql table that keeps track of who is who's friend, for every confirmed friend,...

Automated normalization of mySQL database - how to do it?

I have a mySQL database filled with one huge table of 80 columns and 10 million rows. The data may have inconsistencies. I would like to normalize the database in an automated and efficient way. I could do it using java/c++/..., but I would like to do as much as possible inside the database. I guess that any work outside the database w...

using mysql_real_escape_string to cleans my queries

Is this the best way to do it? Should I do this to every value in every query? GET and POST? Is addslashes(mysql_real_escape_string()) overkill? ...

How to fix "Incorrect string value" errors ?

After noticing an application tended to discard random emails due to incorrect string value errors, I went though and switched many text columns to use the utf8 column charset and the default column collate (utf8_general_ci) so that it would accept them. This fixed most of the errors, and made the application stop getting sql errors whe...

Change Mysql, php and apache2 log file formats

I am sending php errors, all mysql queries, apache2 errors and mod_rewrite debugging to one file, needless to say it's busy in there. Can the format be changed from: [22-Jul-2009 23:00:58] Parameters: GET Array ( ) POST Array ( ) [22-Jul-2009 23:00:58] Finding Associations 237 Query SELECT `table`.* FROM `table...

To make a plan for my first MySQL project

I need to complete the plan of a ask-a-question site for my uni. in a few days. I need to have the first version of the code ready for the next Tuesday, while the end of the project is in about three weeks. Questions about the project which do not fit here to make efficient tables to improve a relation figure to improve a ERD diagram ...

Why Django does not "really" support automatic table update?

Recently I have been trying to learn web development in Django and i am very happy about it... But, one thing is really annoying -especially when you get the idea about 'simplicity' philosophy behind django. It is that updating a table in django is really far away from simplicity as i just experienced. For example, just like the real ...

How do you execute an INSERT statement using MySQL (in c++)?

Google is failing me (or I am failing Google.) I am simply looking for the function that executes an INSERT statement using the mysql.h library in C++. ...

best way to get friends actions for a social network php/mysql

I have a social network similar to myspace but I use PHP and mysql, I have been looking for the best way to show users bulletins posted only fronm themself and from users they are confirmed friends with. This involves 3 tables friend_friend = this table stores records for who is who's friend friend_bulletins = this stores the bulletins...