Hey Guys,
this problem is making me go nuts.
I am trying to do
$query= "insert into page(content) VALUES ('<? include('main.php'); ?> ');
now i know that doesnt work, But i have tried putting in character code for the question mark, the quotes..nothing works.
can you tell me how i can make this work? it works fine on phpMyAdmin
thanks
sincerely,
Inserting PHP code into mysql as part of the query
Moderator: General Moderators
-
tahseenzafar
- Forum Newbie
- Posts: 2
- Joined: Fri Jul 22, 2005 5:23 pm
If you want to contents of the document:
If you want the parsed output of the document:
After that santize it
Code: Select all
$contents = file_get_contents('main.php');Code: Select all
ob_start();
include('main.php');
$contents = ob_get_contents();Code: Select all
$contents = mysql_real_escape_string($contents);I guess your question is quoting problem?
Try this:
Note: Quotes at the and is ' ' and not ".
You don't need to open another php tag.
Try this:
Code: Select all
$query = 'INSERT INTO page(content) VALUES '. include ('main.php');.'';You don't need to open another php tag.