mysql

How to backup MySQL database in PHP?

I got this tutorial from the Internet. But I don't even have a basic understanding on how backup of a MySQL database through PHP would work. http://goo.gl/YK5P Can you recommend some sites that I can use as a reference so that I can study it? ...

PHP5 tier based authorization script?

Are there any PHP login scripts around that I can learn from? I want to have a control panel that shows different options to different users depending on level of privilege. ...

Joining multiple (4) tables in MYSQL

I have four tables I want to join and get data from. The tables look something like... Employees (EmployeeID, GroupID[fk], EmployeeName, PhoneNum) Positions (PositionID, PositionName) EmployeePositions (EployeePositionID, EmployeeID[fk], PositionID[fk]) EmployeeGroup (GroupID, GroupName) [fk] = foreign key I want to create a query t...

Optimize MYSQL (3) Table Join Query

Running an EXPLAIN on some of my query tests have resulted in slow ALL joins even with indexes. How do I make a MYSQL query with the following information more efficient? Tables counter: id (pk), timestamp, user_id (fk) user: id (PK), username, website_id (fk) website: id (pk), sitename SELECT t2.usern...

what's the best way to design dynamic key-value pairs in mysql?

Hi, I need to attach unlimited attributes to a record in a table, and I've already designed a system using #3 below using mysql. Unfortunately I am finding that searching across a million records is getting slow. Is #2 a better approach, or is there a better way alltogether? Is this a case for using a view? I'd like to have my keys ...

Need to build a news article based site - any open source solution I can tweak?

Hi guys - I have a freelance project where I have to build a news articles based website. Let me go over it a bit. The site is such that you have a super admin and you have writers - writers join the website by sending in an application along with a sample of their writing skills - if approved the admin approves them and an account is cr...

Trouble with MySQL UPDATE syntax with the module mysqldb in Python

I am attempting to execute the following query via the mysqldb module in python: for i in self.p.parameter_type: cursor.execute("""UPDATE parameters SET %s = %s WHERE parameter_set_name = %s""" % (i, float(getattr(self.p, i)), self.list_box_parameter.GetStringSelection())) I keep getting the error: "Unknown column 'M...

no module names _mysql; where is _mysql

import MySQLdb and traceback: Traceback (most recent call last): File "D:\zjm_code\sphinx_test\a.py", line 1, in <module> import MySQLdb File "D:\zjm_code\sphinx_test\MySQLdb\__init__.py", line 19, in <module> import _mysql ImportError: No module named _mysql ...

MySQL/Rails Version Control for CMS - How is it usually done?

How do projects like BrowserCMS for Rails implement version control for a CMS? What is best practice for version control with database content? How does it relate to git/svn? ...

Installing mypysql

In the readme file for mypysql, under the Installation section, all that is written is the following: $ svn export http://mypysql.svn.sourceforge.net/svnroot/mypysql mypysql $ cd mypysql $ make compile $ sudo make install Where would I execute such code? ...

MySQL Insert on Duplicate Key.

I am building a rating system, and i want to insert a new row, if the name field does not already contain the name i want to insert, and if it does exist, i want to increase the count field by 1 For example, if i have a row the the name 'Tom' and i try to insert another row with the name 'Tom, then i want to +1 for the field count on th...

Seeding SQLite RANDOM()

Does SQLite support seeding the RANDOM() function the same way MySQL does with RAND()? $query = "SELECT * FROM table ORDER BY RAND(" . date('Ymd') . ") LIMIT 1;"; From the MySQL Manual about RAND(N): If a constant integer argument N is specified, it is used as the seed value, which produces a repeatable sequence of column va...

Exporting MySQL to Excel

Hi, I need some help with this code from PHP Classes, that's supposed to export MySQL to Excel. I'm getting the following error: Parse error: syntax error, unexpected T_SL in excelwriter.inc.php on line 100 This is line 100: [Line100] function GetHeader() { $header = <<<EOH <html xmlns:o="urn:schemas-...

MySQL: Two foreign keys in one table referring to another table

Hi, I've come across something that seemed simple before but has me scratching my head again. I have a table for users: user_id (PK) | username| email | something ... and a table for "views" for when one user has viewed another user: view_id (PK) | viewer_id | viewed_id | view_date The "viewer_id" and "viewed_id" are both user_ids,...

Mysql/Apache connection error from Php script

I am trying to use php. I wrote a small script as instructed in the tutorial. I am using Wampserver 2.0. Connection is fine. But whenever I try to execute the script, I get "Apache HTTP server encountered a problem and needs to close" error message. My localhost is working fine. Normal php scripts without mysql statements in it is workin...

user_id big_int, int or string?

Facebook's user id's go up to 2^32 .. which by my count it 4294967296. mySQL's unsigned int's range is 0 to 4294967295 (which is 1 short - or my math is wrong) and its unsigned big int's range is 0 to 18446744073709551615 int = 4 bytes, bigint = 8 bytes OR Do I store it as a string? varchar(10) = ? bytes How will it effect efficien...

Debugging Stale Ruby Process

Hi, I have a ruby script inside a Rails project. The script includes environment.rb so that Rails gets loaded etc. It then listens to data on a TCP socket of another server, parsing it to keep a mysql database up to date. I'm using the daemons gem to be able to start and stop the process easily. Iv had the script running in production w...

how to get data when we provide multiple value of a field

i got have 3 id in a string let $x="6,3,5" now i want to get all color information from tbl_color where color id are 6, 3 and 5. i made this query, whats wrong with this $sql=" SELECT * FROM tbl_color WHERE color_id IN(".explode(',',$x).") please suggest right query ...

Making a checkbox recognize its intended data

Level: PHP Learner I'm stuck with a checkbox problem. I have a db that contains names and unique id numbers. Using a query, I am pulling a selection of students and showing them to a user in an ultra simple HTML table on a form. Each row begins with a checkbox. The method is POST. So far, so good. My table kinda looks like this:...

MySQL to Oracle help

I have a few questions about using mysql and oracle in a PHP app. 1) Is it possible to code my PHP app to easily switch between these 2 databases? (Use MySQL for a year and then easily switch a "DB" file and it will run on Oracle?) I believe some large PHP projects have support for multiple database types. 2) Does Oracle have some...