Jump to content

Saving a script in mysql


fueltank

Recommended Posts

Hello everyone.

 

I am currently working on a image generator that allows users to work with custom tags (for example something like: "<create width="300" height="200"> etc.) which gets upon sending the form put through a script that translates those tags into php code. So far, so good.

 

Since I'm working on a image generator that will have updated information in the image frequently, I would have to go through all the tags again to create the php code which ofcourse takes a load on the processor when that has to be done each time the image gets called.

 

 

Now to my question. What I would like to do is, after the user sends in the original form I would like to tranlate that form into php code (which is not the problem), and then save that php-code in a mysql database. How can I put a php-script in a mysql database and then call the db-entry and run the script?

 

It's probably something I'm looking over... I hope someone can help me out  :D

 

Thank You.

Link to comment
Share on other sites

you use html as html hard codded on a page ...

 

you can use html in a database but it not advised.....

 

please look up the gd function for images it might help you

to make dynamic images faster and much easer.......

 

html in a database has bad seo ..............

 

else use google..............

 

 

Link to comment
Share on other sites

you use html as html hard codded on a page ...

 

you can use html in a database but it not advised.....

 

please look up the gd function for images it might help you

to make dynamic images faster and much easer.......

 

html in a database has bad seo ..............

 

else use google..............

 

 

 

Thank you for the quick response.

I was thinking about putting PHP code in a mysql database. I'm not sure if that makes a different, but I'll continue my search.

 

Thanks again.

Link to comment
Share on other sites

You coould just use the following

 

$script = htmlentities($script);

$script = addslashes($script);

 

 

 

This will prevent the script from causing any problems in the db

 

Then when you call it from the db you need use

 

$script = stripslashes($script);

$script = html_entity_decode($script);

 

before running it.

Link to comment
Share on other sites

What you mentioned you just need 1 table.

 

userid

imagename

imageid

height

width

 

Then in the name grab the path to the image, pull it out and use the height/width you databased from the user to determine the height/width specs on it.

Use gd/imagemagick to do the scale downs so it doesn't lose quality during all the size changes.

Link to comment
Share on other sites

You coould just use the following

 

$script = htmlentities($script);

$script = addslashes($script);

 

 

 

This will prevent the script from causing any problems in the db

 

Then when you call it from the db you need use

 

$script = stripslashes($script);

$script = html_entity_decode($script);

 

before running it.

 

Thank you. But when I generate a php code from all these tags (the <create .....> was just an example, there are a few more) how would I get that php-code into a variable to be able to save it in a db?

 

Example Code:

	header("Content-type: image/png");
$im = @imagecreate(100, 300);

$font	= "./fonts/verdana.TTF";
$black	= imagecolorallocate($im, 0, 0, 0);

	imagettftext($im, 10, 0, 18, 21, $black, $font, "some text");

         imagepng($im);

 

(I've just put that code together, not sure if it even works). When I generate a code like that, how do I get it into a single variable (+ in the database)?

 

Thank you  again.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.