Jump to content


Photo

Need Some PHP Help


  • Please log in to reply
14 replies to this topic

#1 Beowulf

Beowulf

    Shipgirl

  • Advisors
  • 7,219 posts
  •  Azur Lane Fangirl

Posted 29 March 2009 - 04:02 AM

Yes, it's time to help Fenny with some PHP.

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 Phil

Phil

    Force Majeure

  • Network Leaders
  • 7,976 posts
  • Location:Switzerland
  • Projects:Revora, C&C:Online
  •  Thought Police
  • Division:Revora
  • Job:Network Leader
  • Donated
  • Association

Posted 29 March 2009 - 09:57 AM

Normally what you get from the database are already strings, but that of course depends on your code.
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...

revorapresident.jpg
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 Bart

Bart

  • Network Admins
  • 8,524 posts
  • Location:The Netherlands
  • Division:Revora
  • Job:Network Leader

Posted 29 March 2009 - 04:13 PM

We need more info. Please give some example data from the database and what files exactly should be included for each of them.
bartvh | Join me, make your signature small!
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."

#4 Beowulf

Beowulf

    Shipgirl

  • Advisors
  • 7,219 posts
  •  Azur Lane Fangirl

Posted 30 March 2009 - 04:42 PM

The data is just a URL to a file, which is an HTML template. This is a news script.

I suppose it's a fruitless effort right now though since I had that functionality already and didn't realize it. >_>

NZ.org | BBPCG
Discord: The Astronomer#1314
Steam


#5 Bart

Bart

  • Network Admins
  • 8,524 posts
  • Location:The Netherlands
  • Division:Revora
  • Job:Network Leader

Posted 30 March 2009 - 04:53 PM

The data is just a URL to a file, which is an HTML template.

You mean like file:///home/beowulf/public_html/somefile.html? Or if not, what then?

This is a news script.

Ok, but that doesn't really say a lot.

I suppose it's a fruitless effort right now though since I had that functionality already and didn't realize it. >_>

:p, 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.
The golden rule in programming forums :p
bartvh | Join me, make your signature small!
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."

#6 Beowulf

Beowulf

    Shipgirl

  • Advisors
  • 7,219 posts
  •  Azur Lane Fangirl

Posted 30 March 2009 - 09:48 PM

It's a full URL (eg: http://www.freedomst...lder/afile.html). I wanted to capture that data, churn it into something usable and then display the contents of that file. I'm not really sure how else to describe what I was doing... or trying to do anyway.

Edited by Beowulf, 30 March 2009 - 09:49 PM.

NZ.org | BBPCG
Discord: The Astronomer#1314
Steam


#7 Bart

Bart

  • Network Admins
  • 8,524 posts
  • Location:The Netherlands
  • Division:Revora
  • Job:Network Leader

Posted 30 March 2009 - 10:35 PM

I wanted to capture that data, churn it into something usable and then display the contents of that file.

You should read that and ask yourself "What could I possibly mean here?"

Ideally, you only have one answer. In this case...many :p

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.
bartvh | Join me, make your signature small!
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."

#8 Beowulf

Beowulf

    Shipgirl

  • Advisors
  • 7,219 posts
  •  Azur Lane Fangirl

Posted 01 April 2009 - 04:03 AM

Okay. I'm not sure how to explain it really.

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 Bart

Bart

  • Network Admins
  • 8,524 posts
  • Location:The Netherlands
  • Division:Revora
  • Job:Network Leader

Posted 01 April 2009 - 07:39 AM

Yes but you really need to get into specifics, like how the links are structured, where the actual files are, what you table structure is, etc. Otherwise anyone who wants to help is just reaching in the dark :p
bartvh | Join me, make your signature small!
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."

#10 Beowulf

Beowulf

    Shipgirl

  • Advisors
  • 7,219 posts
  •  Azur Lane Fangirl

Posted 02 April 2009 - 04:03 AM

The 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.

NZ.org | BBPCG
Discord: The Astronomer#1314
Steam


#11 Duke

Duke

    Doctor Doctor!

  • Members
  • 420 posts
  • Location:New Zealand

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.


#12 Beowulf

Beowulf

    Shipgirl

  • Advisors
  • 7,219 posts
  •  Azur Lane Fangirl

Posted 02 April 2009 - 04:56 AM

Now that might work. I'll have to play with that I think. ;)

NZ.org | BBPCG
Discord: The Astronomer#1314
Steam


#13 Bart

Bart

  • Network Admins
  • 8,524 posts
  • Location:The Netherlands
  • Division:Revora
  • Job:Network Leader

Posted 02 April 2009 - 09:08 AM

The 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.

Link structure = URL 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" ;)
bartvh | Join me, make your signature small!
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."

#14 Beowulf

Beowulf

    Shipgirl

  • Advisors
  • 7,219 posts
  •  Azur Lane Fangirl

Posted 02 April 2009 - 06:52 PM

Ohhhh. Full URL. No truncation since the files could come from other sites on my network.

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_*

Guest_Cipblite_*
  • Guests

Posted 20 July 2009 - 10:46 PM

Im also trying to set this up. I had it working at my old host but for some reason cant get it here. I think I might be doing the command wrong, so any help would be appreciated.

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?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users