mysql

What's wrong with my Code?

I am trying to allow users to sort mysql queries based on name, price, etc. This drop down gives them the power to do that, it changes the "ORDER BY" clause based on what the user chooses. It's 3am here and I just can't spot the mistake: <?php $sortBy = $_POST['sortBy']; if ($sortBy) { $priceLowToHigh = ...

Uploading images through PHP into SVN and storing meta data in multiple databases

We're currently designing a rewrite of our PHP website. The new version will be under SVN version control and have a separate database for development and live sites. Currently we have about 200,000 images on the site and we add around 5-10 a month. We'd like to have these images under SVN as well. The current plan is to store and ser...

SQL, counting from 0 to 10

hi. it may sound stupid, but i want to know how (if possible) to count from 0 to 10 by a sql command. i mean i want a sql query which produces one column consisting of numbers from 0 to 10, like this: 0 1 2 3 4 5 6 7 8 9 10 i'm currently using MySQL 5.0 ...

Changing the value of a table field after it has already been inserted

I am working with a CMS system, and using a kind of smartform am inserting fields into a table. In these fields are the name of a product, quantity and cost. cost and product name are taken from a products table, while quantity is input manually. I understand this is not the best architecture, but I am limited with the system I am wor...

How can I get mysql to output a DateTime to Julian day number?

Basically I am using the MySQL gem for Ruby, and I have no reasonable support for date comparison. The Mysql::Time class only gives me only accessor methods like year, month, second, etc. I could do much better date comparison, if I could turn this into a Ruby DateTime object. How can convert MySQL's DateTime field to a Julian day number...

Disallowing characters in a password?

Is there something special about characters that should be allowed/not allowed in a password? I store the password in the db hashed/salted and use PDO to prevent against injection. Is what I'm doing enough? Recently I came across a system that disallowed a number of characters, don't remember all of them, but one was the ampersand &. W...

PHP/MySQL Changing data in a database by clicking a div on the website?

Hi Guys, I have a website that displays a table of a list of people and a value of 1 or 0. If the value is 0 the cell background is green, it ifs 1 its red. How would i make it so clicking the cell will change the value (and therefore colour) and write it to the database? Below is my code. Many thanks, Stephen <? include("dbinfo.inc...

SQL how to count all rows up to a max value

I am having trouble counting the number of rows until it reaches a certain PK. My PK is called id and I want to count all rows until i reach a specified id I have tried using this query but it doesn't work probably becuase I am using a MySQL table select max(count(*)) from news where id=18 group by id I get this error Invalid us...

Ajax autocomple extender from a database

I want to create a textbox (for entering names) in my aspx application which suggests names of Employees from database. I am pasting my code below. I am using Mysql Default.aspx: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register assembly="AjaxControlToolkit" namespace="AjaxC...

What is the correct way to create a database desktop application ?

I just realized that there is no best way to hide MySQL string connection password in my executable file, especially in JAR file. Even encrypting it in EXE would only slow down the process (although I'm not sure how much time would it take to get an encrypted password from an EXE file). So, from my understanding, I need something in th...

SQL using count value as offset

This is a follow on from another question i made I have this query that counts all the records up to a certain point i choose whcih works fine SELECT count(*)FROM news WHERE id < 18 this query gives me a count of 7 I am now having problems with the offset which would be the result of the above query I tried using this query SELECT...

Text in front of variables inside a foreach loop

I have set up a small script to handle a page where I have three checkboxes. The HTML for the checkboxes looks like this: <input type="checkbox" value="Ex1" name="Check[]" />Ex1 <input type="checkbox" value="Ex2" name="Check[]" />Ex2 <input type="checkbox" value="Ex3" name="Check[]" />Ex3 And the PHP script for these: if($_POST['Che...

Select multiple tables when one table is empty in MySQL

I'm trying to do SELECT * FROM a, b However, it doesn't return anything if one of the tables is empty. How do I make it so it returns 'a' even if the other one is empty? ...

Move column into new table in mysql

I'm changing my database structure and I want to do the following thing: I have one table for registered users that holds almost all the information about my site users. There is also one other table that holds information about the amount of points each user have. It has only two columns: user id and points. I want to move the points co...

GPLv3 License use case

If I use Tigase(xmpp server demon) on my server (not distributing it) and build custom plugin(stay within server). Do I have to release my source codes? What if my website have google adsense and If I build some commercial usage plugs for tigase for my own website use. I have no clue how GPL license work for software which we don't distr...

Search for column format

This is a bit of a difficult problem for me to word, and I may be going about it in the completely wrong way. I'm storing a set of options in a database, where each option is its own column. The user can change the number of options, however, so I need a way of allowing PHP to always select all the options. Let's say I have these colum...

Double mysql_real_escape_string insert of new line characters. How to get new line breaks back?

Hi, I have a textarea field that's inserted into a mysql database which may contain line breaks. The textarea data has accidentally gone through two lots of mysql_real_escape_string functions. Therefore the line-break bit of the field data is now stored as "\r\n" instead of an actual new line, as it's been double escaped? Now when writ...

mysql: list of rows in table that aren't referenced in another.

Hi There, I have two tables, timetable and lesson_booking these are linked via timetable_id. timetable represents timetable entries for a given day (mon, tue etc) that can be selected and used to make a booking for a client in lesson_booking What I would like to do is get a list of timetable entries that have no bookings associated w...

How to Store Entire WebPages for Later Parsing?

I've been doing a lot of parsing of webpages lately and my process usually looks something like this: Obtain list of links to Parse Import list into database Download Entire Webpage for each link and store into mysql Add Index for each scraping session Scrape relevant sections (content, metas, whatever) Steps 4,5 -- Rinse/Repeat -- as ...

Can I retrieve pending queries during an InnoDB transaction?

I start a transaction. Then I need to rollback it. Can I somehow get a list of the queries that get "discarded" this way? (ps: of course I can log them beforehand; I was wondering if this could be done in a more "natural" way) ...