mysql

$c = mysql_num_rows(mysql_query($q));

Hi there, I was wondering if this $c = mysql_num_rows(mysql_query("select * from action_6_weekly where code='$code'")); is considered valid PHP? Or do I need to do the following? $r = mysql_query("select * from action_6_weekly where code='$code'"); $c = mysql_num_rows($r); this is what i am actually doing: if($entry == '9') ...

Basics of a remember-me system

Hello, I am using a PHP / MySQL login system. I would like to add a remember-me to it. What are the basic mechanics of a remember-me? Does it involve adding a new column to the table in MySQL where all of the user information is stored, etc. ? Thanks in advance, John ...

What is the SQL MODE in MYSQL (or any RDBMS)?

What is the SQL MODE in MYSQL (or any RDBMS)? Also what is the best option to have for the SQL MODE and Why? If i could have a layman explanation with a example it would be great! Thank you in advance ;-) ...

MySQL Join Query

I need to create a join query for the following: Table supplier: id name Table supplier_vehicles id supplier_id vehicle_id A supplier can have multiple vehicles. On my front-end form I have a checkbox list - a user can select multiple vehicles. The back end script needs to do a search and bring back all suppliers that contain a...

MySQL - Searching in a multiple value field

In my database table I have the following fields: Table Supplier: id name vehicles A supplier can have multiple vehicles. The field 'vehicles' will store multiple values. At the moment I am delimiting the values on a 'pipe' symbol, although this can be changed to a comma if need be. On my front-end form I have a checkbox list - a u...

Securely storing user data in MySQL?

Hello, I'm creating a service that will gather user data such as username, name, email, login password. How do I securely store this data? One thing I was thinking is store it encrypted in the DB so that if anyone gets access to the DB they won't be able to use the data. But that arises two issues - #1 - much much slower search of the ...

mysql index cardinality

I have x row count, but all index cardinarlities are much greater than x, how is this possible? If I understand correctly, index cardinality is the number of unique rows of that index. ...

SHOW TABLES absurdly slow in Rails

For some reason, extremely simple queries, such as SHOW TABLES, can take a long time on my local machine. # line from log/development.log SQL (955.1ms) SHOW TABLES If I execute the same query in dbconsole manually, it runs in < 0.01s Looking through the logs for any long running queries, aside from migrations, they're all SHOW TA...

MySQL error when using send() method of Email component in CakePHP

I've followed the tutorial here: http://book.cakephp.org/view/1286/Sending-a-basic-message, which I have successfully used before with 1.2. However, in 1.3, with a different application, I get the following error: Warning (512): SQL Error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL ser...

MySQL joins with WHERE clause

I have 2 queries which display 2 different values but the results from one query are unexpected. Query1: SELECT SUM(T.amount_reward_user) AS total_grouping FROM fem_user_cards UC LEFT JOIN fem_transactions T USING(card_number) LEFT JOIN fem_company_login FCL ON T.fem_company_login_id=FCL.fem_co...

Is there a shortcut to normalizing a table where the columns=rows?

Suppose you had the mySQL table describing if you can mix two substances Product A B C --------------------- A y n y B n y y C y y y The first step would be to transform it like P1 P2 ? ----------- A A y A B n A C y B A y B B y B C n C A y...

MySQL singleton class conflicts with recursive function (PHP)

I have a MySQL singleton class written in PHP. Its code is listed below: class Database { private $_result = NULL; private $_link = NULL; private $_config = array(); private static $_instance = NULL; // Return singleton instance of MySQL class public static function getInstance(array $config = array()) { ...

What's the difference between utf8_general_ci and utf8_unicode_ci in MySQL?

For a while now, I've used phpMyAdmin to manage my local MySQL databases. One thing I'm starting to pick up is the correct character sets for my database. I've decided UTF-8 is the best for compatibility (as my XHTML templates are served as UTF-8) but one thing that confuses me is the varied options for UTF-8 I'm presented with in the ph...

Quiz - user submissions into MySQL database

Hello What I am trying to achieve: a quiz system with user account and cumulative results table. Process: -User sets up an account -User logs in -User completes quiz -Answers go into results table -Results table displayed My database structure: Table 1: users user_id username password email Table 2: quizzes quiz_id title Tab...

Getting individual counts of a tables column after joining other tables

I'm having problems getting an accurate count of a column after joining others. When a column is joined I would still like to have a DISTINCT count of the table that it is being joined on. A restaurant has multiple meals, meals have multiple food groups, food groups have multiple ingredients. Through the restaurants id I want to be ab...

insert all $_POST data into mysql using PHP?

Hello All, once again I have a question for the STACKOVERFLOW hivemind. Here's the deal, I'm trying to insert all of my $_POST data from a form into a mysql table. Before, I did: INSERT INTO forms (Place, Date, Find, username, who_sponsored, hours, comments, howdiditgo, studentleader_name, studentleader_email, description) VALUES ...

How does hosting work with both PHP/MySQL?

I've never had to purchase hosting for a PHP/MySQL environment before. Usually I just need .NET hosting by itself. If I've ever had a sql backend I usually hosted it myself. How would I setup the MySQL hosting (such as hostname, credentials in my config)? I'm assuming they provide this information? ...

MySQL client portability for my C# app.

I am building an application which needs to connect to a central MySQL database. The application is written in C#. I have installed the .NET connector from MySQL for the VS integration. I was wondering if there is anything special I need to do to be able to have my application be portable and not require an install of the connector on ...

Get percent of columns that completed by calculating null values

I have a table with a column that allows nulls. If the value is null it is incomplete. I want to calculate the percentage complete. Can this be done in MySQL through SQL or should I get the total entries and the total null entries and calculate the percentage on the server? Either way, I'm very confused on how I need to go about separ...

Copy many tables in MySQL

I want to copy many tables with similar names but different prefixes. I want the tables with the wp_ prefix to go into their corresponding tables with the shop_ prefix. In other words, I want to do something like this: insert into shop_wpsc_* select * from wp_wpsc_* How would you do this? ...