mysql

Realtime MySQL search results on an advanced search page

I'm a hobbyist, and started learning PHP last September solely to build a hobby website that I had always wished and dreamed another more competent person might make. I enjoy programming, but I have little free time and enjoy a wide range of other interests and activities. I feel learning PHP alone can probably allow me to create 98% o...

Displaying SQL results using PHP

Hi, I have an SQL query that returns an amount of tuples (about 50). Now I need to display the results, 15 tuples at a time, then I will have a "view more" button to view the next 15 results. Can you please help me how I can make this? The issue is that I cannot use the 'limits' because each time I run the query the results will be dif...

mysql: just select something happen in the weekend

I have a table, store all user created events, and with a field "start_time" and a "end_time" How to select all events just happens in weekend? ...

Ruby on rails active-record generated SQL on Postgres

Dear all, Why does Ruby on rails generated more queries in the background on Postgres than MySQL? I haven't tried deploying Rails on production with Postgres yet, but I am just afraid this generated queries would affect the performance. Do you find Rails with Postgres is slower than MySQL, knowing that it produce more query on the backg...

Sending passwords over the web

So I'm working on a mobile platform application that I'd like to have users authenticate over the web. I was wondering the best way to do security. The user is sending a password for HTTP to a php server wich authenticates against a mysql database on the same server. Obviously I don't want to send the password in plain text over the inte...

MySQL very slow compared to MS Access when inserting hundred of thousands of rows

I am currently adding hundreds of thousands of rows of data to a table first on a MS Access Table then on a MySQL Table. I first tried with MS Access, it tooks less than 40 seconds. Then I tried exactly with the same source and with the same table structure to MySQL and it took 6 min and 40 seconds. That is 1000% slower!!! So is it a m...

How to upload 10 Gb of data to MySQL programmatically without crashing like on PHPMyAdmin?

I'm very surprised that it seems impossible to upload more than a few megabytes of data to mysql database through PHPMyAdmin whereas I can upload a msaccess table easily up to 2 Gigabytes. So is there any script in php or anything that can allow to do so unlike phpmyadmin ? ...

mysql import script by query instead of bash

I have a file called script.sql how can I run that file using q mysql query? global $sql; $res = $sql->query("\. /script.sql")or die(mysql_error()); gives: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\. /script.sql' at line 1 ...

DB Cursor fetching in Web Applications

I never understood this: in web development whe[n|re] does it make sense to fetch results one by one? I mean, why should I use PDOStatement->fetch*() when I can use PDOStatement->fetchAll()? ...

I having a problem with the mysqli free() member function

Hi I have code where I connected to the database like so: $db = new mysqli("localhost", "user", "pass", "company"); Now when I query the database like so: //query calls to a stored procedure 'user_info' $result = $db->query("CALL user_info('$instruc', 'c_register', '$eml', '$pass', '')"); if($result->fetch_array()) { //use the ...

block write access to table from an application in mysql

Hello, We have a CMS plugin that writes statistics to 1 table, this creates performance issues on the entire platform. We decided to use another statistics plugin which can connect to a different database server (the first plugin couldn't!) however we need parts of the first plugin. I want to lock the statistics table to prevent misusa...

What's the best way to store sensitive data in MySQL?

I'm managing the MySQL database from PHP scripts. the communication between server and client is secured via SSL. I store user account data which is sensitive. Is there a way to encrypt this data when entered into the DB? What is the best way to protect this sensitive data? EDIT: I’m using a CRON job for updating data which relies on t...

MySQL sub query

UPDATE members SET money=money+100 WHERE username IN ( SELECT username FROM forum ); Lets say I wanted to give each of my members 100 money for each post in my forum. This query works but if one member has posted more than once, they only get 100. Could someone correc...

Is MySQL Replication Appropriate in this case?

I have a series of databases, each of which is basically standalone. It initially seemed like I needed a replication solution, but the more I researched it, the more it felt like replication was overkill and not useful anyway. I have not done MySQL replication before, so I have been reading up on the online docs, googling, and searchin...

Finding 'free' times in MySQL

Hi, I've got a table as follows: mysql> DESCRIBE student_lectures; +------------------+----------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------------+----------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL |...

Getting MySQL code from an existing database

I have a database (mdb file) that I am currently busy with. I would like to know if it is possible to generate MySQL code that would be used to create this database? ...

MySQL : AVG of AVG impossible ?

Hi, I want to do an average : the problem is for 1 item i'm calculating the AVG of each elements (working) but as soon as i want the GLOBAL average of the averages of the categories (something and foo) it doesn't work (mysql throw me an error : see the syntax i used just below). I need to do that because i want to sort the result by th...

Error when creating database in MySQL using Netbeans 6.8

I am trying to create a database using MySQL statements in NetBeans 6.8. However, I keep getting Error code 1064. I don't know what the problem is really since the same statements work in NetBeans 6.0. Here is the error: Error code 1064, SQL state 42000: You have an error in your SQL syntax; check the manual that corresponds to your MyS...

PHP - file uploads and ways to prevent viruses from being uploaded in zip/rar archives

I am trying to provide a service on my website to allow users to upload files so others can download them. The issue is, since some of these files I will allow to upload will be .zip/.rar files, I am curious as to what ideas exist to help prevent the uploading of archives with Viruses/trojans etc. included. Some .zip files will include ...

Can php query the results from a previous query?

In some languages (ColdFusion comes to mind), you can run a query on the result set from a previous query. Is it possible to do something like that in php (with MySQL as the database)? I sort of want to do: $rs1 = do_query( "SELECT * FROM animals WHERE type = 'fish'" ); $rs2 = do_query( "SELECT * FROM rs1 WHERE name = 'trout'" ); ...