mysql

How do I create a function which puts a unique entry in the sql table or loop?

I basically want to create a unique login varchar in a table based of a first and last name. So Jo Blob signs up and we go: // check to see if username 'JoBlob' exists.... SELECT * FROM special_users WHERE username = $names[0] . $names[1] // if it doesn't exist INSERT INTO special_users username= $names[0] . $names[1] // BUT...

Geo IP database query problem

I'm running this query SELECT country, countries.code, countries.lat, countries.lng, countries.zoom, worldip.start, worldip.end FROM countries, worldip WHERE countries.code = worldip.code AND '91.113.120.5' BETWEEN worldip.start AND worldip.end ORDER BY worldip.start DESC on a tables with these fields, worldip ...

MySql.Data DLL not being copied to output directory

A similar question was asked here without any answers. I have a cs project with a reference to MySql.Data.Dll with CopyLocal=true. When I run the msbuild from command line on one computer (Windows 7 64 bit), it works perfectly. When I run the same MsBuild on another computer (Windows Server 2008 RC2), the DLL is not copied to the output...

Simple SQL (hopefully!) Query Question

Hi I hope someone can help me with my faltering steps to formulate a SQL query for the following problem. I have a simple table that records visitor names and dates. The relationship is many to many, in that for any given date there are many visitors, and for any given visitor there will be one or more dates (i.e. repeat visits). There ...

Why can I select something out of left join on a NULL column?(with contrived example to reproduce it locally,probably a bug!)

VERSION I'm using Server version: 5.1.36-community-log MySQL Community Server (GPL) I've finally contrived a easy example to reproduce it easily! setup: create table t1(id integer unsigned,link integer unsigned); create table t2(id integer unsigned auto_increment,primary key(id)); create table t3(id integer unsigned,content varchar(30...

How to add MySQL support for PHP using MacPorts?

I installed php 5.3 through MacPorts and now i tried to connect to a database (MySQL) but always when i'm trying to call mysql_connect(); im getting an error: Call to undefined function mysql_connect() My setup is: Leopard 10.5.7 Installed and active packages via Macports that may be related to this problem: php5 @5.3.0_2+apache...

Forum Schema: should the "Topics" table countain topic_starter_Id? Or is it redundant information?

I'm creating a forum app in php and have a question regarding database design: I can get all the posts for a specific topic.All the posts have an auto_increment identity column as well as a timestamp. Assuming I want to know who the topic starter was, which is the best solution? Get all the posts for the topic and order by timestamp....

Escaping MySQL characters in .NET

Does anybody have any good .NET functions they can share to escape necessary MySQL query characters? Thanks! ...

How to use MySQL index columns?

When do you use each MySQL index type? PRIMARY - Primary key columns? UNIQUE - Foreign keys? INDEX - ?? For really large tables, do indexed columns improve performance? ...

Getting MySQL error 1064 when performing an INSERT query

What I'm doing is grabbing a feed and inserting the data from each of the feed items. Please see below for the code I'm using. Ok. So I run the page with the query, it loads the feed in to simplexml and I insert the first two items in the feed however I get an error when it gets to the third item. See below for the error I'm getting. I'...

Randomly selecting rows with MYSQL

hi I have a question, to randomly select records from one table do i have to always set a temporary variable in php or what? I basically need some help with selecting random rows with a model in codeigniter and displaying 3 different ones in a view everytime my homepage is viewed. Anythoughts? ...

MySQL query gone wild!?

Can anyone tell me why the following is happening, and how to fix it? I have a MySQL query with an ORDER BY clause that looks like this.. ORDER BY (did_voteup-did_votedown) DESC, did_voteup DESC So it should order the results by their "effective" rating, as in.. 1st. 10 up - 1 down = 9 effective 2nd. 10 up - 5 down = 5 effective 3rd...

Can you edit all columns in a table using phpMyAdmin?

In phpMyAdmin, like the create table view with a spreadsheet of column settings, can you edit a table's columns with new columns, as a similar spreadsheet? ...

Fine-grained access control problem - any ideas?

Hi folks, it's my first post, so be gentle! I'm familiar with a whole bunch of ways to authenticate users for the web-based administration application we're developing, and even various techniques to keep tabs on authorisation... However, my question to you is, how would you recommend I implement a fine-grained access control mechanism...

MySQL: Writing to slave node

Lets say I have a datbase of Cars. I have Makes and Models (FK to Makes). I plan on having users track their cars. each Car has a FK to Model. Now, I have a lot of users, and I want to split up my database to distribute load. The Makes and Models tables don't change so much, but they need to be shared across shards. My thought is to use ...

php function to return SQL results

This is what i have function GetEventsList(){ $result = mysql_query("SELECT * FROM `events`") or trigger_error(mysql_error()); while($row = mysql_fetch_array($result)){ foreach($row AS $key => $value) { $row[$key] = stripslashes($value); } $id = $row['id']; $en = $row['name']; $endt = $row['date']; $push = "<option value=$id>$...

Split data to multiple columns

This is the data currently located in one column: "Title Info - Company Here - City Here, ST" ST represents state ie GA Sometimes my data looks like this: "Title Info - Company Here - United States" Data is on column named "title" and is without quotes. How do I split this using php, for 4 new columns named: "New_Title", "Compan...

Wildcards in GRANT statement?

The following does work as expected: GRANT ALL ON *.* to 'someuser'@'%' identified by 'somepass'; Can I use wildcards for Database name like: GRANT ALL ON someDB*.* to 'someuser'@'%' identified by 'somepass'; ...

How shall i get my friends of friends using mysql and PHP

Currently I am in need to find the friends of friends in my application using PHP and MYSQL For example : Database structure is like this. Table Name : tbl_friendlist Ident mem_id friend_id 1 2 1 2 1 2 3 1 3 1 4 1 5 1 8 How can i achieve this I am...

Mysql inner query not working

$sql= "select tblservergroup.id, tblservergroup.groupname, if(tblservergroup.defserverpaid='0', '0', select concat(tblservers.ipaddress, ' (', tblservers.name, ')' ) as defaultserverpaiddesc from tblservers where tblservers.id=tblservergroup.defserverpaid), if(tblservergroup.defserverfree='0', '0...