Need Some PHP Help
#1
Posted 29 March 2009 - 04:02 AM
Basically, I'm storing a URL in a database table. I have already selected that URL with the SQL but I need to take that URL, convert it into a string and then make that usable for an include/require. I'm stuck on the getting it into a string to make it usable for the inclusion.
Halp?
If it's worth anything, the files to be included are files with HTML in them so I need the HTML to render too. You may have gathered that but if not, there you go.
NZ.org | BBPCG
Discord: The Astronomer#1314
Steam
#2
Posted 29 March 2009 - 09:57 AM
If the value is anything that can be converted to a string you can use (string) $value or strval($value). Obviously you shouldn't do that with objects, arrays, handles, etc. unless you know exactly what you're doing.
Also, I hope I don't need to mention that URI-includes are considered very dangerous and not very portable because any hardened PHP installation has it turned off by default...
My Political Compass
Sieben Elefanten hatte Herr Dschin
Und da war dann noch der achte.
Sieben waren wild und der achte war zahm
Und der achte war's, der sie bewachte.
#3
Posted 29 March 2009 - 04:13 PM
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."
#5
Posted 30 March 2009 - 04:53 PM
You mean like file:///home/beowulf/public_html/somefile.html? Or if not, what then?The data is just a URL to a file, which is an HTML template.
Ok, but that doesn't really say a lot.This is a news script.
, but next time you request help you should specify what you want to accomplish, with as much details as possible. Basically, say what you know and ask where you get stuck.I suppose it's a fruitless effort right now though since I had that functionality already and didn't realize it. >_>
The golden rule in programming forums
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."
#6
Posted 30 March 2009 - 09:48 PM
Edited by Beowulf, 30 March 2009 - 09:49 PM.
NZ.org | BBPCG
Discord: The Astronomer#1314
Steam
#7
Posted 30 March 2009 - 10:35 PM
You should read that and ask yourself "What could I possibly mean here?"I wanted to capture that data, churn it into something usable and then display the contents of that file.
Ideally, you only have one answer. In this case...many
For example, do you want the contents of the file "public_html/somefolder/afile.html" to be displayed? Do you want to get "afile" from the database? Etc.
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."
#8
Posted 01 April 2009 - 04:03 AM
The table houses a link to a template. I established that quite well.
I wanted to capture the contents of the file FROM the database and then display the HTML on a page. That was my aim.
NZ.org | BBPCG
Discord: The Astronomer#1314
Steam
#9
Posted 01 April 2009 - 07:39 AM
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."
#10
Posted 02 April 2009 - 04:03 AM
Though... I'm not quite sure what you mean by the link structure.
NZ.org | BBPCG
Discord: The Astronomer#1314
Steam
#11
Posted 02 April 2009 - 04:11 AM
$curpage = $_GET['page']; $query = mysql_query("SELECT url FROM table WHERE url='$curpage'") if ($inc = mysql_fetch_array($query) { file_get_contents($inc['url']); }
Hm?
Edited by Duke, 02 April 2009 - 04:14 AM.
#13
Posted 02 April 2009 - 09:08 AM
Link structure = URL structureThe table structure for the database is entirely irrelevant since it's just one field I'm yanking from and that part is already easy as can be. The SQL is not the problem. And I said it already, the database table contains a WEB URL to an HTML or other includable file, which is in the database... which I've already stated numerous times.
Though... I'm not quite sure what you mean by the link structure.
Also, you never (with those words) said you wanted to directly include the URL unmodified. So I was thinking of stuff like "http://example.com/test.html" -> "include htmlfiles/test.inc"
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."
#14
Posted 02 April 2009 - 06:52 PM
So like http://www.freedomst...e/somefile.html stays just that. No clipped parts, etc.
NZ.org | BBPCG
Discord: The Astronomer#1314
Steam
#15 Guest_Cipblite_*
Posted 20 July 2009 - 10:46 PM
I put the # thing in my page, as stated before I had it working at my old host.
Right now I have the settings as
/5 /usr/local/bin/php /hsphere/local/home/crabrock/path to file
This is how I had it set up before, but Im not entirely sure on the path I should be using. Is this the correct way to do it?
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users