mysql

Mysql events wont start.

I'm running mysql 5.5.6. It was working, then crashed. I re-installed server, then restored db which has SP and events. My SP show up, but my events dont. The Infomation_schema/events table is blank. I had this problem before, I ran something from C: prompt I cant remember what I did? Its not global event_scheduler problem. The ...

mysql mixed privileges

Hello, I am trying to create a separate set of privileges for a database that contains both "read only" tables and "read write" tables. To be more specific, the database contains 10 tables that I want the user to only read from (i.e. select only). It also contains around 30 tables which the user is free to read and write to and from. La...

MySQL and PHP synchronicity sanity check

I'm troubleshooting a bug and trying to rule out all possible explanations for why I'm witnessing the behavior that I am. I'm executing a number of MySQL queries in PHP (via CodeIgniter's Active Record class) and one explanation for the behavior that I'm seeing is that the queries aren't being executed synchronously, i.e. that PHP isn't...

How do I create user-defined sql functions using CakePHP?

Consider the example given on this page about creating user-defined functions in SQL and then using the user-defined function in the WHERE clause. mysql> CREATE FUNCTION myFunction(in_rep_id INT) -> RETURNS INT -> READS SQL DATA -> BEGIN -> DECLARE customer_count INT; -> -> SELECT COUNT(*) ...

Will more MySql tables slow down searches on MySql database?

I have a classifieds website, and I am thinking about redesigning the database a bit. Currently I have 7 tables in the db. One table for each "MAIN CATEGORY". For example, I have a "VEHICLES" table which holds all information about the following categories of classifieds: cars mc mopeds/scooters trucks boats etc etc ...

Calling MySQL database using Java

Hi I am new to programming and trying to call a table from a MySQL database using Java. Here is what my Java code looks like: public static void main(String[] args){ double p1[] = {10000000,2,5,7,5,6,6,8,9,3}; double p2[] = {100,3,4,3,4,1,2,5,1,5}; double p3[] = {1,2,6,4,5,6,7,8,9,1}; Expert_Score x = n...

c# datagridview and mysql

Hello all, I am doing some c# and mysql and I was successful at getting mysql data into a grid view for the first time! Now, my main question is, how do I manage the grid view style with this? For example, say I have already created columns and such, how do I put the mysql data into a specific column in the grid view? Below is the cod...

Giving a variable a value of 1 or 0 based on whether another variable appears in query results

Hello, I have a query $sqlStr4 that "selects" these fields from a MySQL database: loginid username created The query $sqlStr4 is limited to 10 rows / results. I also have the following variable: $u = $_SESSION['username']; I would like to assign another variable $topten a value of 1 if $u equals any of the ten username fields ret...

Rails/MYSQL - Find all with no association

I have an Employee model and a Shift model. Employees have many shifts and shifts have a date. I want to be able to select all employees that are available for a given date i.e. select all employees where no associated shifts exists for a given date. I can select all employees without a shift like this: SELECT users.* FROM users LEFT ...

MySQL Truncates 0 in VARCHAR field

I have a VARCHAR field in a MySQL table like so - CREATE TABLE desc( `pk` varchar(10) NOT NULL UNIQUE, ... ); The value in pk field is of the type - (xx0000001, xx0000002, ...). But when I insert these into my table the values in pk field get truncated to (xx1, xx2, ...). How to prevent this? UPDATE: Adding the INSERTstateme...

Creating Table FAIL

CREATE TABLE `surfkid-db`.`Channels` (`name` VARCHAR( 30 ) NOT NULL ,`commercial` BOOL( 1 ) NOT NULL DEFAULT '0' AUTO_INCREMENT ,`usrid` INT( 5 ) NOT NULL DEFAULT '0' AUTO_INCREMENT ,`id` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE = MYISAM ; Error: #1064 - You have an error in your SQL syntax; check the manual that corres...

What's the best practice method for storing raw php, javascript, html or similar in a mysql database?

The example web page has 2 fields and allows a user to enter a title and code. Both fields would later be embed and displayed in an HTML page for viewing and/or editing but not execution. In other words, any PHP or javascript or similar should not run but be displayed for editing and copying. In this case, what is the best way to escape...

Changing query ordering based on whether a variable equals 1 or 0

Hello, For the query below, I would like to change the way the results are ordered. Right now, the results are ordered by ORDER BY most_recent DESC. I would like to keep this ordering, but I would like any row where s.topten = 1 to be ordered above rows where s.topten = 0. How can I do this? Thanks in advance, John $sqlStr = ...

PHP not including connection info, what's wrong?

I'm trying to roll a CMS website and I'm on 1and1 Internet's hosting. I'm trying to connect to my MySQL database and I get the following error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) After some frustration, I decided to check my include and it turns out that the following code is not in...

How to force mysql to cache a query for a specific period of time ?

Hi all, is there a way to force mysql to cache a particular query, for say 5 minutes, so executing that query will always return the same result even if the underlying db changes ? i'm running a dating site and i have a page that shows "newest matches" and it's hitting the db too much. thanks in advance. ...

Using multiple tables in iReport

I want to create a report that has to call multiple fields from different tables. From what I have read online so far, the only way to do this is to have subreports. Is this true, or is there a way that I am able to run multiple queries to different tables to retrieve data? ...

How would you do this SQL query?

Let's assume I have 3 tables in a MySQL table with the following fields. product product_id product_name category category_id category_name product_in_category product_in_category_id product_id category_id What query would you recommend to get a list of all products that are not currently assigned to a category in t...

How do I save my current POST array to MySQL

This is my current $_POST output. Array ( [fullname] => John Doe [email] => [email protected] [phone] => 123-455-6444 [address] => 23-10 My Address [zip] => 12345 [fullname_2] => Array ( [0] => M. Owen [1] => V. Persie ) [email_2] => Array ( [0] => mow...

MySQL not working with php; and crashing apache when enabled

I just recently setup a fresh install of PHP, Mysql and Apache on my Windows 2003 server. Php is working fine and my Navicat MySQL browser can connect to my tables. However no matter what I do. MySQL doesn't show in phpInfo() even though I have the extensions in my ext folder. I installed PHP via the windows binary installer. Any idea wh...

Howto: Clean a mysql InnoDB storage engine?

Is it possible to clean a mysql innodb storage engine so it is not storing data from deleted tables? Or do I have to rebuild a fresh database every time? ...