homepage Welcome to WebmasterWorld Guest from 50.19.33.5
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Echo php from mysql
Twisted Mind




msg:1287024
 4:30 pm on Feb 14, 2006 (gmt 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

 

neo_brown




msg:1287025
 5:45 pm on Feb 14, 2006 (gmt 0)

Go to your favorite search engine and look for:
"php mysql tutorial"

DrDoc




msg:1287026
 5:56 pm on Feb 14, 2006 (gmt 0)

echo PHP from MySQL? Like, what do you mean? :)

Twisted Mind




msg:1287027
 6:30 am on Feb 15, 2006 (gmt 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.

DrDoc




msg:1287028
 8:04 am on Feb 15, 2006 (gmt 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.

Twisted Mind




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

k thanku ur my biggest friend :D

Twisted Mind




msg:1287030
 3:59 pm on Feb 15, 2006 (gmt 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?

Twisted Mind




msg:1287031
 6:01 pm on Feb 15, 2006 (gmt 0)

Anyone?

Twisted Mind




msg:1287032
 6:58 pm on Feb 15, 2006 (gmt 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'><?
}}

Twisted Mind




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

plz some1

DrDoc




msg:1287034
 3:32 am on Feb 16, 2006 (gmt 0)

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

[php.net...]

Twisted Mind




msg:1287035
 7:38 am on Feb 16, 2006 (gmt 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..

krakrazor




msg:1287036
 7:51 am on Feb 16, 2006 (gmt 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'>";
}
}

Twisted Mind




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

Both of them do not work

Angelis




msg:1287038
 2:51 pm on Feb 16, 2006 (gmt 0)

Its missing a final?> isnt it?

Twisted Mind




msg:1287039
 3:26 pm on Feb 16, 2006 (gmt 0)

no believe me i tried that :P

DrDoc




msg:1287040
 8:37 pm on Feb 16, 2006 (gmt 0)

The dollar signs need to be escaped as well

DrDoc




msg:1287041
 8:38 pm on Feb 16, 2006 (gmt 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'>\";
}
}

Twisted Mind




msg:1287042
 2:29 pm on Feb 18, 2006 (gmt 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

Twisted Mind




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

So i guess no one is capable of helping me with this?

coopster




msg:1287044
 6:50 pm on Feb 21, 2006 (gmt 0)

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().

Twisted Mind




msg:1287045
 2:30 pm on Feb 22, 2006 (gmt 0)

Im using the echo command on a mysql field wich will be evalled to see the codes check a couple of posts above

coopster




msg:1287046
 5:30 pm on Feb 22, 2006 (gmt 0)

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.

Twisted Mind




msg:1287047
 9:53 am on Feb 23, 2006 (gmt 0)

keh?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved