Welcome to WebmasterWorld Guest from 54.166.117.130

Forum Moderators: coopster & jatar k

Echo php from mysql

   
4:30 pm on Feb 14, 2006 (gmt 0)

5+ Year Member



Is it possible to echo php from mysql? if so how? wich command is this i couldn google it that fast ^^ plz helpzoz me
5:45 pm on Feb 14, 2006 (gmt 0)

10+ Year Member



Go to your favorite search engine and look for:
"php mysql tutorial"
5:56 pm on Feb 14, 2006 (gmt 0)

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member



echo PHP from MySQL? Like, what do you mean? :)
6:30 am on Feb 15, 2006 (gmt 0)

5+ Year Member



hmmz yes that i put php script somewhere in mysql and that i return it in php with a query so i can get different php pages on one index.php.
8:04 am on Feb 15, 2006 (gmt 0)

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member



So, store PHP code in the database ... retreive it with a query ... and then display that as PHP code?

Sure. Just run eval() on the result.

3:16 pm on Feb 15, 2006 (gmt 0)

5+ Year Member



k thanku ur my biggest friend :D
3:59 pm on Feb 15, 2006 (gmt 0)

5+ Year Member



this is strange everytime i put an input box in the code (mysql field) it starts whining about unexpected end.... what can this be?
6:01 pm on Feb 15, 2006 (gmt 0)

5+ Year Member



Anyone?
6:58 pm on Feb 15, 2006 (gmt 0)

5+ Year Member



Well i found out i can add one thing to the inputbox like <input type='text'> or <input name='name'>
But i cant create something like this :
<input type='text' name='name'> then the script wil say:

Parse error: syntax error, unexpected $end in C:\XAMPP\xampp\htdocs\index2.php(21) : eval()'d code on line 10

this is the code in the db:

if (!isset($_GET['action'])){
echo"Action to undertake:<br>
<div style=\"link\">
<a href=\"index2.php?compo=".$_GET['compo']."&action=addcontent\">
Add content</a>
<br></div>";
}else{
if ($_GET['action']=='addcontent')
{
?><input name='sdf' value='fsd'><?
}}

10:14 pm on Feb 15, 2006 (gmt 0)

5+ Year Member



plz some1
3:32 am on Feb 16, 2006 (gmt 0)

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member



The code MUST be a "valid script". You cannot escape out of PHP mode. You cannot have incomplete if/else statements.

[php.net...]

7:38 am on Feb 16, 2006 (gmt 0)

5+ Year Member



The script is valid, It prints out the script even i close and open php?><? the only problem is i cant add 2 things like name and type to an inputbox in the eval script... and i find this wierd i even tried it with echoing it fully in php. echo "<inputbox type=\'blah\' name=\'bla\'>"; but that gives the error too and i fiend this wierd..
7:51 am on Feb 16, 2006 (gmt 0)

5+ Year Member



The bold section is your problem.

if (!isset($_GET['action'])){
echo"Action to undertake:<br>
<div style=\"link\">
<a href=\"index2.php?compo=".$_GET['compo']."&action=addcontent\">
Add content</a>
<br></div>";
}else{
if ($_GET['action']=='addcontent')
{
?><input name='sdf' value='fsd'><?
}}

Try this:

<?php
if (!isset($_GET['action']))
{
echo "Action to undertake:<br><div style=\"link\"><a href=\"index2.php?compo=".$_GET['compo']."&action=addcontent\">Add content</a><br></div>";
}
else
{
if ($_GET['action']=='addcontent')
{
?><input name='sdf' value='fsd'><?
}
}
?>

if that doesn't work... this will:


if (!isset($_GET['action']))
{
echo "Action to undertake:<br><div style=\"link\"><a href=\"index2.php?compo=".$_GET['compo']."&action=addcontent\">Add content</a><br></div>";
}
else
{
if ($_GET['action']=='addcontent')
{
echo "<input name='sdf' value='fsd'>";
}
}

2:48 pm on Feb 16, 2006 (gmt 0)

5+ Year Member



Both of them do not work
2:51 pm on Feb 16, 2006 (gmt 0)

5+ Year Member



Its missing a final?> isnt it?
3:26 pm on Feb 16, 2006 (gmt 0)

5+ Year Member



no believe me i tried that :P
8:37 pm on Feb 16, 2006 (gmt 0)

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member



The dollar signs need to be escaped as well
8:38 pm on Feb 16, 2006 (gmt 0)

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member



if(!isset(\$_GET['action']))
{
echo \"Action to undertake:<br><div style=\\\"link\\\"><a href=\\\"index2.php?compo=\".\$_GET['compo'].\"&action=addcontent\\\">Add content</a><br></div>\";
}
else
{
if (\$_GET['action']=='addcontent')
{
echo \"<input name='sdf' value='fsd'>\";
}
}
2:29 pm on Feb 18, 2006 (gmt 0)

5+ Year Member




Warning: Unexpected character in input: '\' (ASCII=92) state=1 in C:\XAMPP\xampp\htdocs\index2.php(23) : eval()'d code on line 1

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in C:\XAMPP\xampp\htdocs\index2.php(23) : eval()'d code on line 3

Parse error: syntax error, unexpected $end in C:\XAMPP\xampp\htdocs\index2.php(23) : eval()'d code on line 9

6:05 pm on Feb 21, 2006 (gmt 0)

5+ Year Member



So i guess no one is capable of helping me with this?
6:50 pm on Feb 21, 2006 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



How are you running your eval? Are you printing it? Assigning it to a variable? eval() has to be passed valid PHP code, including things like terminating statements with a semicolon so the parser doesn't die on the line after the eval(). Properly escaping the code string is only part of a proper eval().
2:30 pm on Feb 22, 2006 (gmt 0)

5+ Year Member



Im using the echo command on a mysql field wich will be evalled to see the codes check a couple of posts above
5:30 pm on Feb 22, 2006 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



None of the code above shows the syntax of the eval statement. I believe you probably have the syntax off a bit, it can be tricky with the eval statement.
9:53 am on Feb 23, 2006 (gmt 0)

5+ Year Member



keh?
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month