mysql

MySQL query for ALL search terms in index

I have a table of employees and their schedule, like so: Emp_Name | Date -------- ----- Smith | 08-01-2009 Jones | 08-01-2009 Goodman | 08-02-2009 Smith | 08-02-2009 Jones | 08-02-2009 Goodman | 08-03-2009 How would I write a query so that the results were only employee names of employees working on 08-02-2009 and 08-03...

retrieving mysql tables in php

i am fairly new to php and mysql and was incidentally bugfixing a project a friend of mine had done. let me get straight to it. this is a php file that cretaes a temp db: <?php include("config.php"); //define the temp table $query = "CREATE TABLE carttemp( carttemp_hidden INT(10) NOT NULL AUTO_INCREMENT, carttemp_sess...

Sorting search results array by number of matches?

I'm building a basic search function for my site. Realising that the most useful search displays the page with the most counts of the terms given, I coded the following: function search() { $this->page = preg_replace('/[^\w \"\']/i', '', trim($this->page)); preg_match_all('/"(.[^"]+)"|([\w]+)/i', $this->page, $terms); $terms...

Choosing a stand-alone full-text search server: Sphinx or SOLR?

I'm looking for a stand-alone full-text search server with the following properties: Must operate as a stand-alone server that can serve search requests from multiple clients Must be able to do "bulk indexing" by indexing the result of an SQL query: say "SELECT id, text_to_index FROM documents;" Must be free software and must run on Li...

How does a MYSQL Self-Join Work?

I recently asked a question about Self-Joins and I got a great answer. The query is meant to find the ID, Start Date, and Price of Event2, Following Event1 by 1 Day. The code WORKS fine. But I don't understand HOW. Could someone explain as thoroughly as you can- what the different parts of the query are and what they do? SELECT even...

mysql 4.x login problem

Hi I install php 5 and mysql 4.x and mysql 5.x on my windows server. When I try to connect my sql 4 from php myadmin I got access denied for user@localhost USING password : yes I try command line , and inform if I use mysql -uuser -p , I can login wihtout problem but if I use mysql -uuser@localhost -p , I got access denied error. What ...

Converting input time 00 00 AM to DATETIME for MySQL

How can convert my time received from my $_GET variables as two digit values from a menu example: $hours = 04; $minutes = 45; $ampm = 'PM'; into the correct format to insert into a DATETIME field in MySql ...

Is MySQL's COUNT() function an estimate?

I performed the following query on a MyISAM table three times in a row: mysql> SELECT COUNT(*) FROM tickets WHERE created_time BETWEEN UNIX_TIMESTAMP() - 86400 * 20 AND UNIX_TIMESTAMP() - 86400 * 19; The tickets table only receives inserts where the created_time column is set to UNIX_TIMESTAMP(), rows are never deleted, and the create...

Java mysql connection time

I have a java program running 24/7. It accesses mysql database every 3 seconds only from 9.am to 3.PM. In this case when should I should open and close the MySql connection? Should I open and close every 3 sec? Should I open at 9.am and close at 3.pm? Should I open once when the program start and never close it. But reconnect when conn...

Datagrid not updating

con.Open(); MySqlDataAdapter adapter = new MySqlDataAdapter("SELECT * FROM `call`", con); DataSet dataset = new DataSet(); adapter.Fill(dataset, "call"); dataGridView1.DataSource = dataset; dataGridView1.Update(); Here is the above code It runs fine but there is nothing in the datagrid ...

Don't immediatly see the point behind this(php, school)

I'm a 2nd year ICT student. I never did PHP before this year and our instructor gave us the basics and at the end of the semester, gave us a project that would combine what we learned in his course and the databases course. We were to use the classic AMP setup on windows. Now, our instructor told us to make a profile-site, based on how ...

Forum, get last post/topic

Basically, I'm writing a small forum script for an intranet. I've got 3 mysql (MySQLi) tables for the forum: forum_answer - holds replies forum_question - holds first posts forum_categories - holds names and description of categories. Ok, so on the forum index, I've got a table to fetch all the categories, however, I've also one colum...

PHP/MySQL: Retrieving the last Inserted Ids for multiple rows

Hi When inserting data into a table which has an auto-incremented PK, I need to obtain that key for use in another statement. As many questions show on SO this can be done in php using mysql_insert_id(). However, I have been grouping my inserts together so I insert more than one row at a time. I did this as I guessed there would pro...

PHP - mysql_real_escape_string not working

Hey, I have this strange problem. I have this script: echo $comment_content = $_POST['comment_content']; echo $comment_content = mysql_real_escape_string($comment_content); When I run it on my website server, it outputs the value only 1 time (not the second one), but when I run it anywhere else, it outputs right (2 times). However, I...

how to store the pdf file in mysql and retrieve those data

here's my code snippets and the data is not inserting on my database(mySQL).. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); include 'fpdf.php'; class generate extends FPDF{ function out($info,$Bold,$Size,$br){ if ($info != "") { $this->...

MySQL table with only a varchar as a foreign key

Hi, I have a table with a single unique VARCHAR(512) field. I want to have another table hold a foreign key reference to this first table. Both tables use InnoDB. If I add a VARCHAR(512) key to the second table and add a foreign key constraint on it will the 512 bytes long data be held twice? If so, is there a way to hold only a refere...

MySQL server has gone away! Big Headace - Windows 2003 and classic asp

Hi There I was wondering if someone can maybe help me, I am trying to upload a mysql insert command and then get the error Microsoft OLE DB Provider for ODBC Drivers error '80004005' [MySQL][ODBC 5.1 Driver][mysqld-5.0.45-community-nt]MySQL server has gone away In some files it works perfect, but I suspect with this one the file ins...

MYSQL mystery. Value passed to function is incorrect.

When I submit using this function I get an incorrect result for $_REQUEST["add_single"] in the database of 127, incorrect. but the javascript result is 188, correct. If i replace $_REQUEST["add_single"] with 10 I get 10 inserted into the database. if (isset($_REQUEST["add_single"])) { save_single_bracelet($_REQUEST["id"], $_REQUEST[...

Using foreach to update fields in a mysql databse based on another query

Ok I really should be be clued up on this now but its a bit late here in england and I was wondering if someone could point out the obvious to me. I have to do a first query which is SELECT * from table WHERE NOT column=0, and use the results from that to do a foreach loop something like below. foreach($results as $result) { $nox = $r...

What is wrong with this index definition in this MySQL query?

CREATE TABLE `pastebin` ( `pid` int(11) NOT NULL auto_increment, `poster` varchar(16) default NULL, `posted` datetime default NULL, `code` text, `parent_pid` int(11) default '0', `format` varchar(16) default NULL, `codefmt` mediumtext, `codecss` text, `domain` varchar(255) default '',...