mysql

Mysql order by rating - but capture all

Hi, I have this PHP/MYSQL code which returns records from a table ordered by their ratings, from highest rated to lowest rated: <table width="95%"> <tr> <?php if (isset($_GET['p'])) { $current_page = $_GET['p']; } else { $current_page = 1; } $cur_category = $_GET['category']; $jokes_per_page = 40; $offset = ($current...

Php on zend, how to escape a variable for a query?

Hello, im doing some queries in Zend Framework and i need to make sure no SQL injection is possible in the next kind of formats. I can use mysql_escape(deprecated) and wont do all the work. If i try to use real_mysql_escape it wont be able to grab the conection with the database and i cant find how zend_filter would solve the problem. ...

how do I create a mySQL user with hash('sha256', $salt . $password)?

I must be missing something. I want to set up a database user account for select-only transactions but mysql is not letting me choose the hash method for a password on creating a user account. this fails: GRANT SELECT ON myDB.* TO 'selectuser'@'localhost' IDENTIFIED BY hash('sha256', 'salted-myfakelongrandompasswordstring'); ERROR ...

Need to title headers in CSV appropriately, instead of using table column headers

I have a function that exports a table into a CSV file, then I open that file using a spreadsheet application. Is there a way to set the header of the CSV to name each column appropriately. For example: I have a table the contains first name, last name, email, and comments. And the table is set as: fname, lname, email, comments So t...

SQL Join help

<?php $query = mysql_query("SELECT * FROM threads INNER JOIN accounts ON threads.author = accounts.id WHERE id = ".intval($_GET['threadID'])); $row = mysql_fetch_assoc($query); $title = $row['title']; ?> What if I have a column named the same in both tab...

MySql Insert doesn't work when the website deployed on the host!

I'm using XAPP under windows and my website just working well! when I deployed it on the host server, it seems to be working normally, but the insert requests to MySql doesn't have any effect, nothing is changing on the database! Does anyone had this issue before? is there any configuration in MySql to make it accept insert requests? o...

Using Sheevaplug as a basic server to run tomcat and Mysql

I'm probably going to be doing an independent study in College next semester on Java web programming with technologies such as Spring and Hibernate. I'm looking for something that can sit in the corner of my dorm room with out being loud and drawing a lot of power. The machine needs to be able to run a very low traffic tomcat and Mysql s...

Mysql Query not working

I have three tables that are structured like this: http://i41.tinypic.com/2bt9aq.png What I am trying to do is retrieve the joke id, title, and average rating of all jokes in a certain category and order them alphabetically. I have this query: $result = mysql_query(" SELECT jokedata.id AS joke_id, jokedata.joketitle AS joke_title, SUM(...

Creating a flexible update query

Hello, I'm trying to create an flexible update query. I have now something like this: $lsQuery = "UPDATE `"; $lsQuery .= $psTableName; $lsQuery .= " SET "; foreach($psValues as $lsKey => $lsValue) { $lsQuery .= $lsKey; $lsQuery .= " = '"; $lsQuery .= $lsValue; $lsQuery .= "' AND "; } $lsQuery .= "` "; $l...

Odd Mysql issue on insert.

Hy all, Not sure what's going on here, but if I run this: $query = 'INSERT INTO users (`id`, `first_name`, `second_name`, `register_date`, `lastlogin_date`) VALUES ("'. $user_id . '", "' . $first_name .'", "'. $second_name . '", "' . $date . '", "' . $date . ");'; $result = mysql_query($query); I get no return, but if I change it...

Dynamically Query a Database to check for value.

I need to check if a certain value "SheetNumber" is in my mysql database dynamically. I have seen it done on popular web sites and I am trying to find a good tutorial to outline it for me. I am fairly new to Javascript but i know a lot of PHP. I am anxious to learn how to do this. Chris ...

Migrating a MySQL server from one box to another

The databases are prohibitively large (> 400MB), so dump > SCP > source is proving to be hours and hours work. Is there an easier way? Can I connect to the DB directly and import from the new server? ...

Possible JOIN for this query

I have this query: $sql = "SELECT updates.u_id AS u_id, updates.date_submitted AS date_submitted, updates.deadline AS deadline, updates.description AS description, updates.priority AS priority, pages.page_name AS page_name, clients.fname AS fname, clients.lname AS lname, projects.p_...

Porting from MySql to T-Sql. Any INET_ATON() equivalent?

Need to move some code from MySql to TSql. I have a couple of calls to INET_ATON which converts a string which resembles an IPAddress into a number. Is there a T-SQL equivalent? ...

How do you ORDER by title in mysql, ignoring the word "the"?

I have a list of movies that I have grouped by letter. Naturally, the movies starting with the letter "T" have about 80% of movies that begin with "The". Movies such as "The Dark Knight" should appear in the "D" list, and preferably in the "T" as well. Any way I can do that? I use the following code in the WHERE clause to display movi...

Permanently Cache Dynamic PHP/MySQL Forums as Static Pages

I once ran a home-made forum system for a small group of online deathmatch players. These forums have long since been shut down, and are currently offline. What I want to do is create static HTML files that contain all of the data for the entire system, in the interest of having an online archive that the former users could search. ...

Newbie MySQL question - create if doesn't exist otherwise update?

Uhh... kinda strange to put it into words that short. Anyway what I want is in PHP to update an entry in a table if it does exist, otherwise create a new one filling it with the same data. I know that's easy, but I'm relatively new to MySQL in terms of how much I've used it ._. ...

Updating MySQL TIMESTAMP field using time()?

Here is the table of interest when exported via phpMyAdmin: CREATE TABLE IF NOT EXISTS `users` ( `ip` varchar(20) NOT NULL, `lastcheck` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, UNIQUE KEY `ip` (`ip`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; Here is the query: mysql_query("REPLACE INTO users SET i...

mySQL Query to list number of comments my site received each day?

I run an online magazine and would like a dead-simple way to track 3 metrics: How many comments are left each day. How many links my users submit. How many new members I get each day. This information is all my database, I'm just not sure how to get it out. I have a "comments" table with about 3500 comments. Each comment gets a row...

Reversing mysql_fetch_array()

function outputscores($mysqlquery,$reverse=false) { while($row = mysql_fetch_array($mysqlquery)) { echo '<img src="img/date.png" /> ' . date("j M Y",strtotime($row['timestamp'])) . ' <img src="img/time.png" /> ' . date("H:i:s",strtotime($row['timestamp'])) . ' <img src="img/star.png" /> '.$row['score'].$_GET["score...