PHP Programming > General PHP Help
view file
funkyfela:
Hi. I uploaded my file to a directory and the filename is saved in MySQL database, how do I view my file? My code not viewing but displays just file name.
ps: the file is in html and PDF format.
--- Code: ---<?php
mysql_connect("localhost", "user", "paswod") or die(mysql_error());
mysql_select_db("db_name") or die(mysql_error());
$data = mysql_query("SELECT file_name FROM client_file WHERE username = 'john'") or die(mysql_error());
//Puts it into an array
while($info = mysql_fetch_array( $data ))
{
//Outputs the page
Echo "<b>File Name:</b> ".$info['file_name'] . "<br> ";
}
?>
--- End code ---
funkyfela:
I guess this forum ain't the right place to seek help and improvement. Everyone false here is just like me; a tiro
funkyfela:
I guess this ain't the right forum to seek help and improvement. Everyone else here is just like me: a tyro.
richei:
That doesn't output page, just displays what's stored in the database. If you want to view it, then you probably just need to use a simple include.
--- PHP Code: ---<?php
mysql_connect("localhost", "user", "paswod") or die(mysql_error());
mysql_select_db("db_name") or die(mysql_error());
$data = mysql_query("SELECT file_name FROM client_file WHERE username = 'john'") or die(mysql_error());
//Puts it into an array
while($info = mysql_fetch_array( $data )){
//Outputs the page
Echo "<b>File Name:</b> ".$info['file_name'] . "<br> ";
include $info['file_name'];
}?>
--- End code ---
funkyfela:
--- Quote from: richei on July 22, 2012, 04:43:06 AM ---That doesn't output page, just displays what's stored in the database. If you want to view it, then you probably just need to use a simple include.
--- PHP Code: ---<?php
mysql_connect("localhost", "user", "paswod") or die(mysql_error());
mysql_select_db("db_name") or die(mysql_error());
$data = mysql_query("SELECT file_name FROM client_file WHERE username = 'john'") or die(mysql_error());
//Puts it into an array
while($info = mysql_fetch_array( $data )){
//Outputs the page
Echo "<b>File Name:</b> ".$info['file_name'] . "<br> ";
include $info['file_name'];
}?>
--- End code ---
--- End quote ---
thanks. but still didn't work.
error msg: warning: include(file_name) failed to open stream: no such file or directory
Navigation
[0] Message Index
[#] Next page
Go to full version