mysql

MySQL functions don't load when using custom PHP.ini on windows server

php.ini on the server loads mysql functions, but as i have to use a custom php.ini on the site root, after adding the file the server is not loading mysql function. without the custom php5.ini file mysql functions and their values appear in the phpinfo() but when i create the custom php5.ini on the site root and run the phpinfo() mysq...

Grouped/Stratified Reports using PHP and MySQL

I am trying to generate a grouped/stratified report using PHP and MySQL. tbl_items has the following fields: (1) UserName and (2) ItemName A single user can have multiple items listed. I want to generate an output where the data is stratified by each user. For example: *UserName #1 -ItemName 1 -ItemName 2 *UserName #2 -ItemNa...

Uploading HTML into database - PERL

Hi, im trying to upload HTML into a database which does work for some files but not all. my $fileContents; if( $md5Con =~ m/\.php$/g ) { my $ftp = Net::FTP->new($DB_ftpserver, Debug => 0) or die "Cannot connect to some.host.name: $@"; $ftp->login($DB_ftpuser, $DB_ftppass) or die "Cannot login ", $ftp->message; ftp->get("/" ....

retrieve mysql data

I have this code for listing mysql records and putting it into a table according to the address inputted. My problem is, how to do just the same but this time, making use of textboxes to project the contents of the record corresponding to the same data inputted. I'm just a beginner with no talent. Maybe you could give me some idea on ho...

SQL to Update records of one table with records from another table?

Hi guys I need help here again - I have two tables here both contain like lots of records in the tens of thousands. Now we have one main table whose schema is like this: ID | Location Name | Label | Description | Longitude | Latitude And we have another table with: ID | Location Name | Longitude | Latitude The issue is that the longi...

How to get past day from current time in php

I want to calculate whats the date 20 yrs back from current time in php.How can do that.I am not able to figure this out in a proper manner. Scenario is: I am having a column dob in mysql. Now i want to retrieve all the users who age is more than 20yrs and less than 25 yrs. I am using doctrine orm Edit Its working fine but giving a w...

How to get vi keybindings to work in mysql client?

I have vi bindings working in my bash shell using set -o vi in my .bash_profile. But I can't seem to get them to work in the mysql command line client. I only get emacs style bindings. How do you do this? I also put these lines in my .inputrc, but to with no effect: set editing-mode vi set keymap vi ...

MySQL "NULL" questions

I have a table with several columns. Sometimes some of these column fields may be empty (ie. I won't use them in some cases). My questions: Would it be smart to set them to NULL in phpmyadmin? What does the "NULL" property actually do? Would I gain anything at all by setting them to NULL? Is it possible to use a NULL field the same w...

List items by category

Hello I have 3 tables: category doesnt matter item2cat: itemID|catID item: id|name|desc I want to list the items that are in the given category, but I don't know how to do it in a simple way. (With PHP and MySQL) I need this table-structure because I want multiple categories to one item. ...

concurrent mySql database queries

Hi I'm running mySql server that being updated every 4 hours. In the mean while data can be retrieved. Does mySql handle this scenario where the DB is being updated and a query from the user is received? or I should handle this scenario? Is it possible to create a snapshot of the DB just before the update takes place and query this D...

Mysql Average on time column?

Hi i have this query: SELECT avg( duration ) as average FROM `login`; The datatype for duration is "time", thus my value is like: 00:00:14, 00:20:23 etc I execute the query it gives me: 2725.78947368421 What is that? I want in time format, can mysql do the average on time?? ...

SQL: replace with few records (mysql)

There's an index table. (Links tags with ids). REPLACE INTO com_index (word, ids) VALUES ('word1', concat(ids, ' 2')), ('word2', concat(ids, ' 2')) word is a primary key. I try to look through rows, add ' 2' to ids in those of them, which exist; and create a new row with ' 2' if it doesn't. So, I need to look if there's any row wit...

Little explanation of this mysql code

I got this answer from somebody on another Q before, but I would like to get an explanation of this, so that I fully understand the problem. I have a table, with a column which contains a value of either "private" or "company". Thing is, I want to check how many "private" and "company" values are in my records, so that I can display the...

Count rows from results of a "mysql_query"

If I have this: $results = mysql_query("SELECT * FROM table_name WHERE id=$id"); is there then any way to check how many rows which have a field-value of "Private" or "Company" ? I need to show the user how many "Private" and "Company" records where found, without making another query. (There is a column called 'ad_type' which contai...

Matching two columns in MySQL

I'm quite new to SQL and have a question about matching names from two columns located within a table: Let's say I want to use the soundex() function to match two columsn. If I use this query: SELECT * FROM tablename WHERE SOUNDEX(column1)=SOUNDEX(column2); a row is returned if the two names within that row match. Now I'd also like t...

sql query number of parent

i have table called type ID Name ParentID --------------------- 1 name1 0 2 name2 0 3 name3 1 4 name4 2 5 name1 1 i need to know how many parent (descendants) each type have EX: ID -------- descendants ID-> 1 (have no parent) ID-> 3 (have 1 parent (ID->1)) ID-> 5 (have two parent ((ID->3(ID...

How do I JOIN these tables?

I have two tables: **WEEK** -id -week # **ITEM** -id -name -is_marked -week # My final desired result is to have a table that has a rowspan="3" table cell with week # in it, followed by the three results for each week from SELECT * FROM item WHERE week = week_number AND is_marked = 1 I don't know if I need to JOIN anything bec...

Keeping data plus index-data in memory - InnoDB vs. MyISAM

Assume a database consisting of 1 GB of data and 1 GB of index data. To minimize disk IO and hence maximize performance I want to allocate memory to MySQL so that the entire dataset including indexes can be kept in RAM (assume that the machine has RAM in abundance). The InnoDB parameter innodb_buffer_pool_size is used to specify the si...

Best practice for a local database cache?

I am working on an application that depends on a MySQL database for parts of the content. In some cases, the application will run in an environment with limited internet connectivity (UMTS), in particular suffering from high latencies. A user of the application is able to login, and most of the content for the user interface of the app...

Reorder integer except for value 0 with sql

I'm trying to get an ordered list of rows out of my MYSQL database table based upon an integer value 'place'. SELECT * FROM mytable ORDER BY place; This works okay, except that all rows with value place=0 should appear at the end of the table. So if my table is: name place ---- ----- John 1 Do 2 Eric 0 Pete 2 it should become: ...