473,382 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

echoing PHP code from a database?

I have the following data in a MySQL database:
<a href="<?php echo $server; ?>Sugapablo-Stick_It_To_The_Man.mp3"

let's call it $row[0].

when I echo $row[0], the php code is shown as opposed to the value of
$server.

How can I get the value of $server to appear? str_replace?

--
Sugapablo
------------------------------------
http://www.sugapablo.com <--music
http://www.sugapablo.net <--personal

Jul 17 '05 #1
3 2157
Sugapablo <ru********@sugapablo.com> wrote in
news:vm************@corp.supernews.com:
I have the following data in a MySQL database:
<a href="<?php echo $server; ?>Sugapablo-Stick_It_To_The_Man.mp3"

let's call it $row[0].

when I echo $row[0], the php code is shown as opposed to the value of
$server.

How can I get the value of $server to appear? str_replace?


eval

--
Peter Strömberg
C2K2 C2K3 ISCCIV02
Jul 17 '05 #2

"Sugapablo" <ru********@sugapablo.com> wrote in message
news:vm************@corp.supernews.com...
I have the following data in a MySQL database:
<a href="<?php echo $server; ?>Sugapablo-Stick_It_To_The_Man.mp3"

let's call it $row[0].

when I echo $row[0], the php code is shown as opposed to the value of
$server.

How can I get the value of $server to appear? str_replace?

--
Sugapablo
------------------------------------
http://www.sugapablo.com <--music
http://www.sugapablo.net <--personal


have you made sure your data is safe? If the data is not safe and you
execute it you leave yourself wide open for problems... However... if I make
the assumption that your data is safe and you want to execute/evaluate the
contents of $row[0] as if it were a real function you could try something
like this:

<?
$row[0];
?>

or

<?
$commandString=$row[0];
$commandString;
?>

That should do it... if not, you might need to use html_entity_decode, for
example:

<?
$commandString=html_entity_decode($row[0]);
$commandString;
?>
Jul 17 '05 #3
I tried eval, and I tried a couple of other things, noe worked well enough.

I found the best to be a simple str_replace() function.

I just wanted other opinions to see if something would work better.

Thanks for the help. :)
--
Sugapablo
------------------------------------
http://www.sugapablo.com <--music
http://www.sugapablo.net <--personal

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Margaret MacDonald | last post by:
Probably it's something dumb that I'm doing/not doing, but echo doesn't seem to want to echo a literal zero when the value of some var is zero. E.g.: $foo = 0 ; echo 'foo is ' . $foo ; ...
3
by: vorange | last post by:
Hello, I have a problem I have been unable to solve for quite some time now. I'm using the Serialport class and opening the port and writing a byte to it. The byte is successfully received by...
3
chunk1978
by: chunk1978 | last post by:
hi there... can someone tell me how i can display my echo statement correctly? i'm using french characters but the output is crazy... my php code: <?php echo "Montréal"; ?>
2
by: jonathan184 | last post by:
Hi I am trying to use if statements to search strings on each line and if it finds matches to the string write to a variable and then echo variable and the loop starts again. The match is being...
5
by: rogeranthony | last post by:
Can anyone explain why this doesn't work? <?php $message = "hello world"; function func1() { echo $message;} func1(); ?> I'm new to PHP and I must be missing something incredibly basic!
21
by: fjm | last post by:
Hello everyone. :) I knew it wouldn't be very long before I was back with another question. I just created a login box on my site and I am having an issue with trying to echo an error back to...
1
by: chocciies | last post by:
Hi! I want to delete multiple record via checkboxes. However, with no success. Is there sthg wrong with the value of my checkbox? Your help will be greatly appreciated. Thanks! <form...
3
by: BryanA | last post by:
I have a site that I need to generate a sitemap for. It is way to big for a desktop program to crawl or any of the online sites. It technically only has 4 pages but it runs from a DB with a couple...
1
by: harryusa | last post by:
Here I am trying to write a file with a directory path like d:\\$directory1\$directory2\$file.txt So I have variables in between backslashes and I keep getting errors like: Warning: Unexpected...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.