mysql

How and when to update a MySQL index?

I'm using this SQL query to create an index: $query = "CREATE INDEX id_index2 ON countries(geoname_id, name)"; How do I update the index when new entries are added? Should I run a PHP script with the update query in CRON and run it every night? Is this best practice for automated index updating? ...

php echo doesnt print newlines

Hey ! I started doing a new project in PHP / MySql . The Aim of this project is to manage articles for a magazine that i am the editor of. So the content of the articles, i decided i would store with the "TEXT" column type of MySql Now when i retrieve this column and print it with echo, the newlines are not there. Its all on the sam...

mySQL Efficiency Issue - How to find the right balance of normalization...?

I'm fairly new to working with relational databases, but have read a few books and know the basics of good design. I'm facing a design decision, and I'm not sure how to continue. Here's a very over simplified version of what I'm building: People can rate photos 1-5, and I need to display the average votes on the picture while keeping tr...

How do I write a prepared statement with an update?

I am using mysqli prepared statments and I am trying to write a prepared statement with an UPDATE, but I think I am off somewhere. Here's my code: $upload_folder = 'Some String'; $sql = 'UPDATE orders (upload_location) SET (?) WHERE order_id = 160'; $stmt = $conn->stmt_init(); if($stmt->prepare($sql)){ $stmt->bind_p...

Extra fulltext ordering criteria beyond default relevance

I'm implementing an ingredient text search, for adding ingredients to a recipe. I've currently got a full text index on the ingredient name, which is stored in a single text field, like so: "Sauce, tomato, lite, Heinz" I've found that because there are a lot of ingredients with very similar names in the database, simply sorting by rele...

getting data problem with MYSQL under linux

Hi all, Recently I started to use Linux (Ubuntu 9.10) instead of windows. I am working on a java web application with Spring, MYSQL with jpa. However, before to install linux I made a backup file from the database, then installed linux, installed the MYSQL Query Browser and Administrator tools, and using the Admin tool restored the back...

MYSQL distinct query

This is my example of my table: id | name | foreign_id | 1 a 100 2 b 100 3 c 100 4 d 101 5 a 102 6 b 102 7 c 102 I would like to get the distinct file with the latest foreign_id (bigger number but not necessarily biggest). In this example, it would be row with id 4,5...

Improve performance of website

I have designed a new web site. I have hosted it online. I want it to be of the best performance and load pages faster. This website is designed in php 5.0+ using codeigniter. This is using mysql as DB. I have images on it. I am using Nitobi grid for displaying set of records on page. The rest is everything normal page controls. As i ...

Does MySQL support historical date (like 1200) ?

I can't see any info about that. Where can I find the oldest date Mysql can support ? ...

database for streets world wide?

i use the downloadable geonames database for all countries, states, counties and cities in the world. but i wonder if there is a database for streets? so you could pick: country -> state/department/district -> (county/region) -> city -> street in whatever country you like? cause when i do a search for a street in google map i can see ...

PHP While Loops from Arrays

I have a table that contains members names and a field with multiple ID numbers. I want to create a query that returns results where any values in the ID fields overlap with any values in the array. For example: lastname: Smith firstname: John id: 101, 103 I have Array #1 with the values 101, 102, 103 I want...

How to log user actions with php and mysql?

I'm working on my CMS and I want it to log activities by users and other admins. For example: when new user registers or admin makes a new news post -> update last activity. I want to know what is the best and easiest way. ...

the data can't display in the form....

about my system the university complaint..stud or staff can use this system to complaint. first user fill the form complaint and submit after submit user can view the complaint.now the problem is the complaint can't display.... this code for user complaint(userCampus.php): ?php // ------------------------------------------------------...

VBA How to find last insert id?

I have this code: With shtControleblad Dim strsql_basis As String strsql_basis = "INSERT INTO is_calculatie (offerte_id) VALUES ('" & Sheets("controleblad").Range("D1").Value & "')" rs.Open strsql_basis, oConn, adOpenDynamic, adLockOptimistic Dim last_id As String last_id = "select last_insert_id()"...

status update error (null field)

hai guys... i .ve the problem that i cannot be recovered yet... i have one form where admin need to approve or reject the booking request... i've set the b_status field in table usage IN PROCESS default value... i want to update the b_status value BOOKING APPROVED when user click APPROVE button.. otherwise, the b_status will update the v...

Extending URIs with 2 queries (i.e. 'viewauthorbooks.php?authorid=4' AND 'orderby=returndate") Possible?

I have a link in my system as displayed above; 'viewauthorbooks.php?authorid=4' which works fine and generates a page displaying the books only associated with the particular author. However I am implementing another feature where the user can sort the columns (return date, book name etc) and I am using the ORDER BY SQL clause. I have th...

Warning: mysql_real_escape_string()?

Hi, I am getting the error; Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) Why do I get this error? The mysql_real_escape_string() works on all of my pages apart from one? Is it something to do with MySQL being on a different s...

Getting mysql syntax error and cant find source

I have function that updates log table. function wslog($userID, $log, $where) { safe_query("INSERT INTO ".PREFIX."log ( time, userID, log, where ) values( '".time()."', '".$userID."', '".$log."', '".$where."' ) "); } And I have this php code: wslog($userID, 'server|'.mysql_insert_id().'', 'servers'); But I keep getting syntax e...

Why can I not view foreign language characters in my mysql DB?

I am inserting the following characters into my DB: 汉字 / 漢字 This is the meta tag on the page that is inserting the characters: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> I have altered all the columns in my table that is holding the characters to be utf8_unicode_ci The foreign characters show up like so in...

Mysql syntax using IN help!

Hi, i have a pictures table : pictures(articleid,pictureurl) And an articles table : articles(id,title,category) So, briefly, every article has a picture, and i link pictures with article using articleid column. now i want to select 5 pictures of articles in politic category. i think that can be done using IN but i can't figure out ho...