Welcome to WebmasterWorld Guest from 23.20.221.93

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Echo php from mysql

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

Full Member

10+ Year Member

joined:Oct 12, 2005
posts:275
votes: 0


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)

Junior Member

10+ Year Member

joined:Oct 2, 2003
posts:129
votes: 0


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

Senior Member

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

joined:Mar 15, 2002
posts:6807
votes: 0


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

Full Member

10+ Year Member

joined:Oct 12, 2005
posts:275
votes: 0


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)

Senior Member

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

joined:Mar 15, 2002
posts:6807
votes: 0


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)

Full Member

10+ Year Member

joined:Oct 12, 2005
posts:275
votes: 0


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

Full Member

10+ Year Member

joined:Oct 12, 2005
posts:275
votes: 0


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)

Full Member

10+ Year Member

joined:Oct 12, 2005
posts:275
votes: 0


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

Full Member

10+ Year Member

joined:Oct 12, 2005
posts:275
votes: 0


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)

Full Member

10+ Year Member

joined:Oct 12, 2005
posts:275
votes: 0


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

Senior Member

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

joined:Mar 15, 2002
posts:6807
votes: 0


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)

Full Member

10+ Year Member

joined:Oct 12, 2005
posts:275
votes: 0


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)

Junior Member

10+ Year Member

joined:Feb 7, 2006
posts:42
votes: 0


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)

Full Member

10+ Year Member

joined:Oct 12, 2005
posts:275
votes: 0


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

Full Member

10+ Year Member

joined:July 8, 2005
posts:348
votes: 0


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

Full Member

10+ Year Member

joined:Oct 12, 2005
posts:275
votes: 0


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

Senior Member

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

joined:Mar 15, 2002
posts:6807
votes: 0


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

Senior Member

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

joined:Mar 15, 2002
posts:6807
votes: 0


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)

Full Member

10+ Year Member

joined:Oct 12, 2005
posts:275
votes: 0



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)

Full Member

10+ Year Member

joined:Oct 12, 2005
posts:275
votes: 0


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

Administrator

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

joined:July 31, 2003
posts:12541
votes: 1


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)

Full Member

10+ Year Member

joined:Oct 12, 2005
posts:275
votes: 0


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)

Administrator

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

joined:July 31, 2003
posts:12541
votes: 1


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)

Full Member

10+ Year Member

joined:Oct 12, 2005
posts:275
votes: 0


keh?