mysql

Replacing a string in a text field

Hello, I have a column in my database table which has lows of text and lows of rows. In the text, a url needs to be changed for every row. In each row the url can exist more than once. Can I use the replace function to change all the urls in the text field in my database table without affecting the rest of the text in that same col...

PHP AJAX UPLOAD ?

I am having problem uplaoding file, here are my codes: Any help? Thanks! test.html function insertPhoto() { var description = document.getElementById('description').value; var image = document.getElementById('photo').value; var url = "ajax_insert.php?action=add&image="+image+"&description="+description; var ajaxRequ...

How to store the timestamp as decimal(17,3) in mysql?

I try to generate a trigger, in the trigger statement I have to set a column of type decimal(17,3) with the actual timestamp or the seconds of unix timestamp, but could not find a solution. ...

PHP/MySQL Secure Login & Sessions

I have a login service to my current website and what I was wondering is - is there any particular method you could call the MOST Secure? Allow me to explain my system a little better: I currently have a PHP MySQL database with a users table. The username and password are both stored as VARCHAR (not the best for passwords I know). On ...

MySQL databases mysterious table deletion

Hi, I need some advice on how to track down a weird occurence on one of my servers. I'm not a linux expert so please bear with me if I haven't explained properly. We have a test server that is running apache, php5, mysql, postgresql on linux OS. Recently the mysql database have had all tables removed apart from a few. I've investigat...

PHP MySQL: Saving PDF to Database

I am generating PDFs with TCPDF, I want to save the generated pdf as blob in a MySQL db. What data should I save to the db? Code for PDF page <?php require_once('../config/lang/eng.php'); require_once('../tcpdf.php'); // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); //...

How to write better this Mysql Join query

I have the next tables Users {id, name} Messages {id, user_id, cache_user_name} What I want is to do a JOIN only when cache_user_name is NULL for performance reasons. For example: SELECT Messages.*, Users.name FROM Messages INNER JOIN Users ON (Messages.user_id = Users.id) // ON (ISNULL(Messages.cache_user_name) AND ... The best...

Using Doctrine with views - dud 'id' field generated

I have a DB (yes, that one) which is proving far easier to access via views than raw tables. In general this plays quite nicely with Doctrine, but there's one issue. Doctrine can't identify a primary key in a view table when generating the YAML from the database schema, so it invents one called 'id'. Generating classes from this means th...

Cannot modify header information Warning message in PHP?

php code- $q = "Update tblarticle set art_title='$title', art_cat='$cat', art_des='$txtart' where art_id='".$_GET['art_id']."'"; $result = $mysqli->query($q) or die(mysqli_error($mysqli)); if($result) { //saved succesfullt $error =0; header("location:mngArt.php"); exit; } else $error =1; } ?> ....Some HTML........ da...

Codeigniter - sort retrieved values from MySQL

Hi, Is it possible to sort the values retrieved from MySQL, in say descending id? Thanks. ...

Remove trailing newline

I've a MySQL database from which I extract a string which is a list of words separated by newline. Now I want to remove only the trailing newline. I tried using preg_replace as $string = preg_replace('/\n/','',$string); It works but all the newlines in the strings are removed :( Please help Thanks everyone. ...

Differences between "IS NULL" and "ISNULL()" in Mysql

There is any difference in performance between the operator IS NULL and the function ISNULL() ? ...

Mysql Trigger error

1.I m using mysql 5.2.2 version 2.I create table in my test database CREATE TABLE account (acct_num INT, amount DECIMAL(10,2)); 3.I also Create trigger CREATE TRIGGER ins_sum BEFORE INSERT ON account FOR EACH ROW SET @sum = @sum + NEW.amount; 4.I insert data into account table INSERT INTO account VALUES(137,14.98),(141,1937.50),...

How to prevent replication of certain records with mysql

I have master-master replication working successfully, it works fine and all changes I make will reflect to slave also. But I don't want that slave to reflect all changes - only such records that I want should reflect on slave. How can can do this? ...

PHP/MySQL group news/archives by year then month

Hi, I've got some code which outputs a news archive sidebar. It all works very well apart from the fact that it doesn't split the months by year properly. Rather than assigning the relevant month to its year, all months are being shown for all years! Very frustrating! Any help would be greatly appreciated. $query = "SELECT * FROM isnew...

How to check a data row in mysql with triggers?

Hello! I want to be sure, that there are no children of children in my datatable. So if I have a parent item A, and a child item B (B.parent = A), and I try to insert a child item C to the item B (C.parent = B), this trigger have to prevent it and set the parent_id of C to A (C.parent = A). I need only 2 levels in my table (parent-chil...

Download Mysql binary data

I have a few files saved in a mysql table. What is the best way to download one of the files? I am using MySQL Query Browser. When I right click on choose "save field content", a file gets downloaded, but it is unreadable (corrupt). ...

Using union and order by clause in mysql

I want to use order by with union in mysql query. I am fetching different types of record based on different criteria from a table based on distance for a search on my site. The first select query returns data related to the exact place search . The 2nd select query returns data related to distance within 5 kms from the place searched. T...

MySQL Book/Tutorial/Video for Beginner?

I have download and install MySQL and once I start the programme I knew I need further help. I found few title by O'Reilly. 1) High Performance MySQL 2) MySQL Cookbook 3) MySQL in a Nutshell 4) MySQL pocket reference 5) Managing and Using MySQL Please recommend which book is for database. If you know any tutorial/video which is availa...

How do you return to the start of a Mysql::Result result set

If you use something like each_hash to loop over a Mysql::Result set in Ruby when using the Mysql gem then you end up at the end of the result set and any subsequent each_hash loop doesn't have anything to loop over. I see there is a Mysql::Result#row_seek method, which expects a Mysql::RowOffset object. But I'm unable to find any docum...