mysql

MYSQL Limit inconsistent

$data = mysql_query("SELECT * FROM phpbb_posts ORDER BY post_id DESC LIMIT 4") or die(mysql_error()); Above is my code and I'm having problems with the Limit part. When I first set it, everything seems perfect, but I could come back in a few hours and look at the page again and a different number of records could be shown, even though ...

Getting only the default image for a property

I am trying to retrieve a list of properties and to do this I have to tie together 4 tables. The tables are: property, property_type, state, and photo. The problem is getting ONLY the default image for a property. The photo with the lowest rank number should be the default. So if there are 2 photos for property 10, than the one with t...

Select statement help.

Hi, there I am coding a blog post kind of thing, where the author will post the article and it will be displayed in the front end, my problem starts for selecting the posts as i have to meet certain conditions for posting the news in the front end, I have 4 fields in the database namely title pic_title pic_brief pic_detail you gues...

Is it possible to perfom a fulltext search against a joined column?

Hello I' trying to select from joined column: SELECT A.idAd, A.ads_in_Cat, A.title, A.currency, A.price, A.in_dpt, A.description, D.*, S.* FROM ads A LEFT JOIN dept D ON D.id_dept = A.in_dpt LEFT JOIN sub_cat_ad AS ON S.id_sub_cat = A.ads_in_Cat WHERE MATCH(A.title, A.description) AGAINST(:searchTerm) ...

MySQL table PRIMARY KEY question?

I' was wondering should my primary key look like this PRIMARY KEY (id, category_id, posts_id) or look like this PRIMARY KEY (id)? Here is my MySQL table. CREATE TABLE posts_categories ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, category_id INT UNSIGNED NOT NULL, posts_id INT UNSIGNED NOT NULL, date_created DATETIME NOT NULL, PRIMARY KEY...

Best storage engine for high volume, static analytics data

I'm building an application that requires storage and querying of very large amount of timestamped data. Specifically, this is analytics type data whereby a particular "set" can contain up to 100 separate data points tied together via a shared timestamp. This data is static, in that it will never change once stored but may be queried mul...

MySQL Function to Determine Zip Code Proximity / Range

I have been able to create php function to determine a list of zip codes within a certain range of a given zip code. However, my next task is a bit more complex. Lets say the table has the following columns: id, username info latitude longitude range Each record has a unique row id, some information, a latitude, a longitude, and a ma...

PHP & MySQL function delete unchecked categories from database problem.

I have a PHP function that allows users to pick which categories there post should be displayed in. I want to be able to delete a users picked category from the database when they unchecked a check box. But everything I tried seemed to delete all the users categories or not work at all. Can someone help me with this problem? Here is par...

subtracting timestamps

I thought this would be a really simple thing, but I'm having a hard time finding any answers! I have a support table, with added_on and closed_on fields that track when support tickets were opened and closed. I'd like to run a query that (closed_on - added_on) to show the duration a ticket was open. Both fields are timestamp format. T...

bind expression problem

I want to show a collection of images in list view. I have an image table in a MySQL database, the fields are photoId, PhotoName, ... I want to bind the image control Url in the item template of the list view on the physical path (stored in config file) + photoName in the DB. ImageUrl ='<%# ConfigurationManager.AppSettings.GetValues("...

SQL highscores.

Ok, I have two MYSQL tables: CREATE TABLE `sessions` ( `id` int(11) NOT NULL AUTO_INCREMENT, `userID` int(11) NOT NULL, `runTime` int(11) NOT NULL, `monstersKilled` int(11) NOT NULL, `profit` int(11) NOT NULL, `tasks` int(11) NOT NULL, `xpGain` int(11) NOT NULL, `lastupdate` int(11) NOT NULL, PRIMARY KEY (`id`) ); An...

How to use an auto incremented primary key as a foreign key as well?

Hello This is what I'm trying to do: I have 2 tables... CREATE TABLE `parent` ( `id` int(11) NOT NULL AUTO_INCREMENT, `data` text, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; CREATE TABLE `child` ( `parent_id` int(11) DEFAULT NULL, `related_ids` int(11) DEFAULT NULL, KEY `parent_id` (`parent_i...

Using LEFT JOIN inside datatable server side script

dear all, i'll take some data from the database. and join two tables.the code like: SELECT DATE(A.Inspection_datetime) AS Date, A.Model, COUNT(A.Serial_number) AS Qty, B.Name FROM inspection_report AS A LEFT JOIN Employee AS B ON A.NIK = B.NIK GROUP BY A.Model, A.Serial_number i want show this data using jQuery dataTable....

MySQL Error #1366 -- Chinese Characters Fail with big5_chinese encoding

The idea: I'm just trying to save some Chinese characters to a MySQL database. The issue: apparently, some save while others don't. I've tried to just put em in via phpMyAdmin, but when I try to save them, they turn out to be question marks "?". The query: UPDATE a9286500_chinese.chinese SET chinese = '贵' WHERE chinese.id =23 LIMIT 1 ;...

Insert a ♥ into MySQL (heart character) via PHP

I'm having a heck of a time getting ♥ type characters into my database using php. I've got UTF-8 setting on the page <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> and <?php $line = $_REQUEST['line']; $line = stripslashes($line); $line = htmlspecialchars($line); $line = trim($line); $line = mysql_real_escape...

Questions about building a website

Just a couple questions about building websites. I know the basics of building a website, but there are a few things I was wondering about. The first thing is about posting on the main page. What I mean is if I want to set up an admin page where me or the other admin want to login and fill in the box and click post, how do you post to an...

How to import Apache access log into MySQL table?

What is the recommended approach to import Apache access log into a MySQL table? I am thinking of a ruby/perl script + a cron job. It'll be great if there is an example or reference. I am not sure how to handle the bookmarking of the last log entry in last import either. Suggestions are welcome. Thanks! ...

User-created database structure: non-relational or relational databases?

I want to have dynamic fields in my database records. For example: I want to build an application for users to create their own forms. A user could create the following forms: Personal profile: Full Name Street Job Phone Home Work Mobile Interests Interest 1 Interest 2 Interest 3 Work: First name Last name Work Department ...

How to quickly develop a sortable, paged data grid of a MySQL table in PHP?

How do I quickly develop a sortable, paged data grid of a MySQL table in PHP/JavaScript? If the grid could sort/page and download data via AJAX it would work better, of course :) I could develop it manually using AJAX to update the datagrid on sort/page navigation, but I was wondering if any datagrid components already existing that wo...

PHP EMAIL HELP!

I have encounter an error Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\works\test\registration-code3.php on line 56 any help? here is my php.ini define_syslog_variables = Off [mail function] ; For Win32 only. ;...