mysql

How to perform a mysql query after reading session values

Hello, I am using this script to read a value in a session, then I want to query the database about this value : <?php session_start(); $user_id = $_SESSION["user_id"] ; echo "Your user_id is: $user_id \n" ; $query = sprintf("SELECT * FROM `customers` WHERE id='%s' ", $user_id); $result = mysql_query($query); if (!$result) { ...

MySQL Migration to OSX?

Hello all i look around for software to MySQL Migration som bardy maby can help me? i use OSX platform, and relly confurse over i can't get a software for this. i use a lot of time to look 2 database its "up2date" sombardy can maby help? or maby MySQL scripting i need? donno i hob for helping to mysql Migration software on osx. ...

How to optimize this query to get rid of subqueries?

I have a database with 2 tables: Table 1: CREATE TABLE IF NOT EXISTS `sales` ( `sale_id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `sale_total` int(11) NOT NULL, `sale_date` date NOT NULL, `sale_status` int(11) NOT NULL, PRIMARY KEY (`sale_id`) ) ; Table 2: CREATE TABLE IF NOT EXISTS `users` ( `user_...

multiple processes

I am using openSUSE & mysql table with 25 million records. I am doing some stress testing & came accross something: I am running 2 perl scripts that access mysql....each will select a record one at a time at random then get another record & so on. So far, so good. Let's call these process A & process B. Now, I want to kick it up a not...

Mysql how to set time data type to be only HH:MM in database

Hi, how can I set my mysql database field "time" data type to only be HH:MM in the database, in my script the user only enters HH:MM and the DB automatically adds the last :SS digits, the problem is when I pull that value to edit, it adds the last digits also, which is kind of annoying, I can get rid of it with PHP and truncating off the...

How do I run a function on each argument in a varargs list in C

I wish to Call mysql_real_escape on each argument of a vararg list before it is then passed on to vsprintf to include into an SQL string, is there anyway I can do this easilly? Seems I missed prepared statements, this seems to be usefull though anyway. ...

How to select an entire database and display all the information.

Is it possible to select all the tables from a database (not knowing their names) and displaying them? My friend has a mysql server but he doesn't have phpMyAdmin installed and he's begging me to transfer all his php-fusion accounts to his new WordPress blog. He doesn't understand a thing with mysql... Anyone got an idea? ...

How can I offer user generated websites with PHP/MySQL?

I am getting started on a new project and I haven't been able to find a pre-packaged solution that will allow me to offer users the opportunity to create an account and use my templates to create their own web page/site that is hosted on my server. I'm sure there is something out there I can use and modify, but if I'm wrong, what is the...

Forget Password Page//...using PHP MySQL

Please guys help me with the code,...! Here we have a forget.php page (which enable user to change his pass)... When some body enters an e-mail id existing in mysql database, then an e-mail is sent to the user about a unique code which is stored in the database along with username, password, e-mail id and conf (explained later). user cl...

Poor MySQL Join Performance

I've been trying to perform a join on two tables in MySQL, and the query will run for a minute or two before I run out of memory without getting results. I'm far from a database expert, so I'm not sure if I'm writing my queries poorly, if I have some MySQL settings poorly configured, or if I really should be doing something else entirel...

Complicated Sub-query - is this possible?

I've got 2 tables: one stores tags, the other stores articles. There's a mode "Get articles by tag", which basically takes all articles, tagged "x". In my articles table I use a filed, called Tags, that stores data in such pattern 'tag1, tag2, tag3, ...'. So I want to get everything work by just a single query like that: SELECT *, ...

MySQL: Update all rows in a table matching results of another query

I've written a query returning rows associating Customers and Salespeoeple. Note that the query joins several database tables. And note that not all customers have a salesperson. c_id c_name s_id s_name 24 microsoft 1 mike 27 sun 1 mike 42 apple 2 bill 44 oracle 1 mi...

update rows with duplicate entries

I have the same situation as this other question, but I don't want to select the rows, I want to update these rows. I used the solution Scott Saunders made: select * from table where email in ( select email from table group by email having count(*) > 1 ) That worked, but I wanted to change/update a row-value in these entries, so ...

heroku db:push failing (randomly?) w/ "duplicate key value violates unique constraint"

I'm trying to push a large database (1.6 GB over 8 tables) to Heroku via db:push and having strange issues. It keeps failing, at different points in the transfer process, with: HTTP CODE: 500 Taps Server Error: PGError: ERROR: duplicate key value violates unique constraint "letters_pkey" letters is a large table (1.3 M records) b...

iOS with JSON, PHP

I'm rather new to ios and json. I've managed to create a db in mysql and used php to create a basic read and write php pages. I'm using the TwitterHelper class from cs193p class for the presence assignment from Stanford to acces the php interface online and tie it to my ios code. I am getting an error which I can't solve. Update: O...

Fixing N+1 queries in Rails that need a counter.

I'm pretty new to optimizing my queries, I have an N+1 query and it seems it needs a counter, but I'm not really sure how to proceed: ... SQL (0.5ms) SELECT COUNT(*) AS count_id FROM (SELECT 1 FROM `photos` WHERE (`photos`.attachable_id = 4864 AND `photos`.attachable_type = 'Recipe')) AS subquery SQL (2.1ms) SELECT COUNT(*) AS count_i...

Close all mysql connections from workbench

Hello I keep on getting the max_user_connections error on mysql What I want to do is close every connection through something like workbench.. Anyone know how, on mysql workbench? Thanks ...

MYSQL disable SELECT BENCHMARK

Hi, how would I disable the mysql benchmark function, thus not being subject to blind sql injection attacks such as "select if( user() like 'root@%', benchmark(100000,sha1('test')), 'false' );" select * from func does not show up a function benchmark. Kind Regards Charles ...

HELP TCP Server in C cannot save in MYSQL !

I'm developing a TCP Server in C language that can save data to mysql. The problem is "buf" cannot be save/insert into mysql. But "name" can be save/insert into mysql. Do u know what is the problem is? and how to fix that? I'm very glad if u can help me. below is the code. to compile : gcc -o tcpecho $(mysql_config --cflags) tcpecho....

PHP/MySQL Insert

Ok I have been using PHP + MySQL for a while so I consider myself proficient. I have made my fair share of syntactical mistakes in the past but this is honestly pissing me off: http://img251.imageshack.us/img251/3760/fubar.png If anyone can tell me why this simple statement isn't working I would be greatly appreciative. ...