mysql

Configuring authentication and authorization in Apache2 with MySQL

Hello, I am trying to configure Apache2 so I can use MySQL for authenticating users to access certain pages. Also authorization needs to work so different groups can reach differen pages. Now, I have googled a lot but can't find out how to do this. At least not for the configuration I am having. There doesn't seem to be any version of...

Only one row returned in mysql data retrieval

Firstly, sorry about the long question... but this is doing my head in. Any help would be greatfully accepted. I've written the following function to return data from a mysql database: function injuryTable() { # get all players that are injured and their injuires... $sql = "SELECT players.id, players.injury_id, players.pname, i...

Adding text from mySQL table to Middle of URL in PHP page

Hi fellows! I'll try to ask this correctly. This has got me licked. I have a script online that will bring up items according to a search on let's say, page1.php. The results come from a table called items. The results list has links to the items that look like this: a href=\"/" . "boats/$name/" . "$p". $line["PID"]. ".html\" In anothe...

How to return data fetched from MySQL into a php file as JSON?

I have to return data fetched from MySQL table into a php file as JSON. Here is my code to connect to mysql & get data from it. How could now I return it as JSON. <?php $username = "user"; $password = "********"; $hostname = "localhost"; $dbh = mysql_connect($hostname, $username, $password) or die("Unable to...

How do I track overhead of establishing/closing mysql connections

I'm trying to determine if I should be using persistent connections or not. How can I track the overhead of establishing/closing mysql connections in PHP? ...

finding related items using mysql?

im trying to figure out how to find related topics items using mysql & php, this is my table for topics topics{id, topic, founder,vote_up, vote_down date} for instance say i was on topic page of php topic {3,php,getaway, 6, 8, 20.06.2009 ect] how would i find all the related topics to this topic: if you get what i mean:)) thanks, ...

MySQL - change many rows of dates

I have a fairly large number of rows where a datetime field is stored such as: 0010-01-03 00:00:00 But, I need it to be: 2010-01-03 00:00:00 Any suggestions on how to mass change rows from 0010 to 2010? ...

Mysql Startup Timer

MySQL starting up events. Is there a way to get MySql to run events during the week and not run events on Sat and Sundays. Thinking global events = on, But how would get the events to turn off on Sat or Sun at startup. ...

Which of those 2 MySQL queries is more efficient?

SELECT * FROM openorders_tracking WHERE id NOT IN (SELECT tracking_id FROM openorders_commission) SELECT * FROM openorders_tracking LEFT JOIN openorders_commission ON openorders_tracking.id=openorders_commission.tracking_id WHERE openorders_commission.id IS NULL I'm wondering both specifically for this query, and in general if...

How do you make a social network badge?

You see them everywhere. Like the twitter and facebook buttons that show up on blogs and websites that display a number of "tweets" or "likes". All I need to be able to do is display a number from my MySQL database based on two variables (username and an ID). It would probably be useful to encrypt the variables somehow so that users can'...

create mysql database on mac os x

I know this sounds a little ridiculous, but I'm just honestly wondering how I can create a MySQL database on my Mac OS X machine. I have MySQL installed (as far as I know) as well as PHP, and I'm wondering how I can create one. I have downloaded a sample PHP ecommerce site to kind of delve into what I'm trying to familiarze myself with...

Is there a way to get XML results from MySql 5.1 ?

I need to select a single row from MySql and get the results as well-formed XML, where the XML tags are the column names. Is there some built-in way to do this, or will I need to manually assemble the XML? I want something like this: < id >2< /id > < name >John Smith< /name > < age >34< /age > Just to clarify and elaborate... ...

UNIX timestamp issue on MYSQL insert via PHP

Im receiving data with a created time field given in a unix timestamp format for example "1251324809" which to my understanding is the amount of time elapsed since the epoch, 1970. Ive got a DATETIME formatted field in a MYSQL table, and im using this to return the UNIX time to a YY-MM-DD HH:MM:SS format: date('Y-m-d H:i:s', $timestamp...

SQL Insert from another table

I can use some help with a sql INSERT. words_table contains productid word product table contains productid description I'd like to create a row in words_table that contains the productid and the word "foundit" for each row in product table WHERE description LIKE '%keyword%'. and I'm not sure how to do it. Thanks ...

Select rows with highest version for a shared key

Here's the Schema in mysql: CREATE TABLE IF NOT EXISTS `labs_test`.`games` ( `game_id` INT NOT NULL AUTO_INCREMENT , `key` VARCHAR(45) NOT NULL , `config` BLOB NOT NULL , `game_version` BIGINT NOT NULL DEFAULT 1 , PRIMARY KEY (`game_id`) , INDEX `key` (`key`(8) ASC) , INDEX `version` (`game_version` ASC) ) ENGINE = InnoD...

MySQL hook up to a website ?

Hi, I am trying to develop a WebSite for my Church. I don't have much experience in IT, but I have a home page with html and css right now. I would like to have a database that I could hook it up to.. Are there any basic tutorials on how to do this? I am running linux mint. and My website is PHP. How could i hook up a MySQL Database...

Create MySQL database on server

I'm following a tutorial for constructing a PHP and MySQL ecommerce driven website, and I'm uploading them to my server at the moment, but in need of some assistance determining how to proceed. In the README of the tutorial, are the following instructions: INSTALLATION INSTRUCTIONS 1.) Unzip plaincart.zip to the root folder under your...

How do I configure Rails to output decimals to the correct precision in form fields?

I want to store currencies in my (sqlite and mysql) databases. I'm trying to use the decimal column type, with :scale => 2. This isn't behaving as expected. If I save a record with :rate => 10.50, it is stored in my sqlite db as 10.5. In addition, when I output the value in a form field, it is displayed as 10.5. I don't want to do hack...

How do I create a random 4 digit number in mysql

I have a table of several hundred users and I want to create a 4-digit pin code like those used at an ATM machine for each user using an UPDATE statement. They don't have to be unique, but I don't want to use an autonumber type of field so one company cannot easily guess the pin code of another user. What is the simplest and easiest way ...

Making a query ordering condition dependent on the age of a variable

Hello, The query below works well. However, I would like to modify it. I would like the ordering by when s.topten = 1 then 0 else 1 end to only be done when s.datesubmitted was less than 24 hours from the present time. How can I do this? Thanks in advance, John $sqlStr = "SELECT s.loginid, s.title, s.url, s.displayurl, s.datesubm...