html in myql with php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
johniem
Forum Commoner
Posts: 29
Joined: Mon Jul 20, 2009 8:58 am

html in myql with php

Post by johniem »

What is the safest and most working way to store an html page in mysql batabase?
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Re: html in myql with php

Post by shiznatix »

use field type "text" or one of the "blob" types depending on how much HTML there is I guess. Your question is quite vague, maybe you could explain more what you are trying to do and what part of the security you are worried about.
johniem
Forum Commoner
Posts: 29
Joined: Mon Jul 20, 2009 8:58 am

Re: html in myql with php

Post by johniem »

i'm using tinymce on my cms to make and store html pages..I'm passing the html code to a php script
and using mysql_real_escape_string() to escape the string with the html code. I have disabled the magic_quotes on my server but the query is not working.

Code: Select all

 
$content = mysql_real_escape_string($content);
$query = "INSERT INTO galeries (ARTICLE_ID,CONTENT) VALUES (" . $articleId . ",'" . $content . "')";
$result = mysql_query($query);
 
johniem
Forum Commoner
Posts: 29
Joined: Mon Jul 20, 2009 8:58 am

Re: html in myql with php

Post by johniem »

I just solve the problem...it wasn't the html document that causing the problem.
I was selecting which database i will use, inside the function and i pull it out at the begining of the script and it worked...seems weird though..

Anyway...i was always wondering the best sequence to follow, manipulating the string that contains the html code, before storing it in database. So any advice will be really nice..
Post Reply