mysql

How to limit a MySQL Distance Query

I'm trying to preform a distance calculation to return a listing of places within a certain distance. This is based on using a zip code database and determining the distance from the origin to each location. What I want to do is limit the results to be within a certain distance from the origin, but I'm having trouble with my MySQL query....

Looping through input form problem

I'm having an issue when I loop through form input text fields. I am trying to loop through multiple text fields labeled 'number' and it's only submitting the very last number field instead of all 'number' fields. Can anyone see what I'm doing wrong here?? for ($i = 0; $i < count($_POST['number']); $i++) { $sql='INSERT INTO o...

what does this integer mean?

hi people i am new at php and wondering what does int(4) mean in creating this table. thanks for helping. CREATE TABLE mytable( name VARCHAR (50), age INT(4), email VARCHAR (50) ); ...

Update with an incremented value based on corresponding row

Here's a problem for the PHP-juggler in you. I want to use plain-ol' mysql_* functions of PHP. I have the following MySQL table: +-----+-----------------+ | id | thread | +-----+-----------------+ | 14 | 01/ | | 14 | 02/ | | 14 | 03/ | | 15 | 01/ | | 22 | 01/ |...

Trying to join data from two mysql tables in order to sort by it.

I'm currently working on Drupal site, building a custom JSON module for a project at work. I'm trying to join data of events from the drupal node table to a date field associated with it, stored in another table. This cannot be altered. What i want to do, is run a query to fetch the list of events from the node table, and but i need to...

Doing multiple MySQL counts in one query?

Hey guys..... now I know the below query isn't valid, but I'm just using it as an example as what I'm trying to achieve. Basically what I want to do is get a COUNT() of all the rows & then also get a COUNT() of rows with a condition clause in the one query. Such as.. SELECT COUNT(*) AS full_amount, COUNT(address IF NOT NULL),...

Sanitizing MySQL Queries without preprared statements (PHP + old mysql module)

Note: I've looked at this question: http://stackoverflow.com/questions/1238763/preventing-sql-injection-without-prepared-statements-jdbc . And as I somewhat expected... the answer is to use prepared statements. I'm in a different set of circumstances... so I'd like to know the best path for this. I'm using a downloaded script (phpsimple...

AJAX MYSQL JQUERY PHP - TOUGH, TRIVAL QUESTION - Try yourself!! :)

This is a quiet trival question. Here goes: Trying to use AJAX / JQUERY to create a text field. As soon as I start writting on the text field, it should dynamically link to a new page with the text field (and its values) on top that page without reloading the page. So, for instance, as soon as I type "S" (for "StackOverFlow") in the te...

Need help understanding MySQL injection

From http://www.tizag.com/mysqlTutorial/mysql-php-sql-injection.php I got: SQL injection refers to the act of someone inserting a MySQL statement to be run on your database without your knowledge. Injection usually occurs when you ask a user for input, like their name, and instead of a name they give you a MySQL statement...

How can I find and replace in MySQL?

I need to change the server paths that were stored in my database (Wordpress), so I am searching for the string "/home/". Is there some kind of command such as str_replace($search, $replace, $subject) equivalent in SQL? Edit: What if I don't know what the field name is? Well, I do, but there is more than one field name. I was just hopi...

Under what scenarios would one want to connect to a host other than localhost?

What I mean is when: mysql_connect('localhost', 'root', 'root'); I provide 'localhost' as the first argument without ever stopping to think what purpose it serves. I guess the opposite would be remote host, but when would you actually use it? Hope it is not a too stupid question, but I really dont know why its there... ...

How to INSERT INTO a MySQL table using ON DUPLICATE KEY UPDATE?

How to INSERT INTO a MySQL table using ON DUPLICATE KEY UPDATE so that if the row already exits one of the columns of the row gets it value plus 1? So, if I have two columns titled ip and count, the count column contains 1 in the first place and increases its value on every next UPDATE. Can we do that in one single statement? ...

How best store year, month, and day in a MySQL database?

How best store year, month, and day in a MySQL database so that it would be easily retrieved by year, by year-month, by year-month-day combinations? ...

Using Python to write to HTML file with MySQL data as source ?

Hi all, I am trying to generate some simple html pages that contain data stored in a MySQL database. I have searched and searched for an answer to this and while I can successfully generate html pages from txt or user input I can't get it working with SQL. I am not worried about formatting the data in html or anything, that I can work o...

ASP.NET 4 , VSD2010 and MySQL 5 make connection using ASP.net

Hi, I am trying connect to MySQL database from ASP.net code. some my connection is not working. for the below code I am getting invalied argument DRIVER. Can you help me to correct this. Or show me some sample code. Label1.Text = "" Label2.Text = "" Try Dim conStr As New SqlClient.SqlConnection ...

PHP/MySQL Link Each Word

Hello, I have a PHP script that pulls keywords from a MySQL database and I need help with figuring out how to link each word. An example MySQL entry: cow moo white black Need to output in link form: <a href=word.php?word=cow>cow</a> <a href=word.php?word=moo>moo</a>, etc. Thank you ...

delete rows from a table when a specific row from another table has been deleted

I have Group and each group has contacts associated with it. When a user deletes a group, if the group is not empty then it will alert them that all contacts in that group will be deleted if they continue. Well anyways, so my problem is setting up that feature. I have tried to figure out how I can delete all contacts that belong to that...

Storing html code in the sql database problem

I want to store an HTML code in an SQL database. It stores everything fine except when there are attributes defined such as border="0". I think single quotation mark is not an issue. How do i avoid this from happening. The error: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version ...

DBI database handle with AutoCommit set to 0 not returning proper data with SELECT?

This is a tricky one to explain (and very weird), so bear with me. I will explain the problem, and the fix for it, but I would like to see if anyone can explain why it works the way it works :) I have a web application that uses mod_perl. It uses MySQL database, and I am writing data to a database on regular basis. It is modular, so it ...

Speeding up large numbers of mysql updates and inserts

I have an app that needs to update a large amount of data over a large number of entries. Basically it does some 7,000 inserts and/or updates but it takes a looooong time (like almost 9 minutes... averaging about 0.08 seconds per query). Essentially I'm looking for general speed ups to making multiple such requests (I'm not expecting a s...