MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old April 15th, 2003, 05:48 AM
jackeapen jackeapen is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 3 jackeapen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Blobbing data with MYSQl and PHP

hi,
i tried to incoporate a script to my site as per the directions in the article by Mitchell Harper at URL
everything seems to be fine except, i can't view my files other than the HTML files.
showfiles.php is showing the type of files exactly. but when i click on download.php i'm getting a blank page for all file types other than .html files. where may be the problem?
plz help me

Reply With Quote
  #2  
Old April 16th, 2003, 03:59 AM
fakker fakker is offline
The calm b4 the storm
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Manchester, UK
Posts: 404 fakker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via Yahoo to fakker
hey jackeapen,

welcome to the devarticles forums!!

cold you post the code which you've got so far? then we can determine the problem (hopefully!! )
__________________
Matt 'Fakker' Facer

mattfacer.com

Reply With Quote
  #3  
Old April 16th, 2003, 11:57 PM
jackeapen jackeapen is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 3 jackeapen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hi,
here r the codes which i use. plz try to find out the problem

##### upload.php
__________________
html>

<head>

<title> Upload a File </title>

</head>

<body bgcolor="#FFFFFF">

<form enctype="multipart/form-data" name="frmUploadFile" action="grabfile.php" method="post">



<table border="0" cellpadding="0" cellspacing="0" bordercolor="#111111" width="100%">

<tr>

<td width="100%" bgcolor="#FF9900" height="22" colspan="2">

<p style="margin-left: 10"><b><font face="Verdana" size="2" color="#FFFFFF">

Upload a File</font></b></td>

</tr>

<tr>

<td width="100%" bgcolor="#FFE3BB" colspan="2">

<p style="margin-left: 10; margin-right: 10"><font face="Verdana" size="2">

<br>Please select a file from your local computer to upload to our web server

for saving in our database. This file can be of any type you like. Once you

have chosen a file, please click on the "Upload this file" button below.&nbsp;

&nbsp;<br>&nbsp;</font></td>

</tr>

<tr>

<td width="15%" bgcolor="#FFE3BB">

<p style="margin-left: 10"><font face="Verdana" size="2">

File Description:</font></td>

<td width="85%" bgcolor="#FFE3BB">

<input type="text" name="strDesc" size="20" maxlength="50"></td>

</tr>

<tr>

<td width="15%" bgcolor="#FFE3BB">

<p style="margin-left: 10"><font face="Verdana" size="2">File Location:</font></td>

<td width="85%" bgcolor="#FFE3BB">

<font face="Verdana" size="2">

<input type="file" name="fileUpload" size="20"></font></td>

</tr>

<tr>

<td width="33%" bgcolor="#FFE3BB">

<p style="margin-left: 10"><font face="Verdana" size="2">

<br>

<br>

&nbsp;</font></td>

<td width="67%" bgcolor="#FFE3BB">

<font face="Verdana" size="2">

<input type="submit" value="Upload this file" name="cmdSubmit"></font></td>

</tr>

</table>

</form>

</body>

</html>

######grabfile.php

<?php

// GrabFile.php: Takes the details

// of the new file posted as part

// of the form and adds it to the

// myBlobs table of our myFiles DB.



global $strDesc;

global $fileUpload;

global $fileUpload_name;

global $fileUpload_size;

global $fileUpload_type;


// Make sure both a description and

// file have been entered

if(empty($strDesc) || $fileUpload == "none")

die("You must enter both a description and file");

// Database connection variables

$dbServer = "localhost";

$dbDatabase = "openbiblio";

$dbUser = "admin";

$dbPass = "admin";

$fileHandle = fopen($fileUpload, "r");

$fileContent = fread($fileHandle, $fileUpload_size);

$fileContent = addslashes($fileContent);

$sConn = mysql_connect($dbServer, $dbUser, $dbPass)

or die("Couldn't connect to database server");

$dConn = mysql_select_db($dbDatabase, $sConn)

or die("Couldn't connect to database $dbDatabase");

$dbQuery = "INSERT INTO myBlobs VALUES ";

$dbQuery .= "(0, '$strDesc', '$fileContent', '$fileUpload_type')";

mysql_query($dbQuery) or die("Couldn't add file to database");

echo "<h1>File Uploaded</h1>";

echo "The details of the uploaded file are shown below:<br><br>";

echo "<b>File name:</b> $fileUpload_name <br>";

echo "<b>File type:</b> $fileUpload_type <br>";

echo "<b>File size:</b> $fileUpload_size <br>";

echo "<b>Uploaded to:</b> $fileUpload <br><br>";

echo "<a href='upload.php'>Add Another File</a>";

#####showfiles.php

<?

$dbServer = "localhost";

$dbDatabase = "openbiblio";

$dbUser = "admin";

$dbPass = "admin";



$sConn = mysql_connect($dbServer, $dbUser, $dbPass)

or die("Couldn't connect to database server");


$dConn = mysql_select_db($dbDatabase, $sConn)

or die("Couldn't connect to database $dbDatabase");



$dbQuery = "SELECT blobId, blobTitle, blobType ";

$dbQuery .= "FROM myBlobs ";

$dbQuery .= "ORDER BY blobTitle ASC";

$result = mysql_query($dbQuery) or die("Couldn't get file list");


?>


<table border="1" cellpadding="0" cellspacing="0" bordercolor="#111111" width="100%">

<tr>

<td width="34%" bgcolor="#FF9900" height="21">

<p style="margin-left: 10"><b><font size="2" face="Verdana" color="#FFFFFF">

Description</font></b></td>

<td width="33%" bgcolor="#FF9900" height="21">

<p style="margin-left: 10"><b><font face="Verdana" size="2" color="#FFFFFF">

Type</font></b></td>

<td width="33%" bgcolor="#FF9900" height="21">

<p style="margin-left: 10"><b><font face="Verdana" size="2" color="#FFFFFF">

File</font></b></td>

</tr>

<?php

while($row = mysql_fetch_array($result))

{

?>

<tr>

<td width="34%" bgcolor="#FFDCA8" height="21">

<p style="margin-left: 10; margin-right: 10">

<font face="Verdana" size="1">

<?php echo $row["blobTitle"]; ?>

</font>

</td>



<td width="33%" bgcolor="#FFDCA8" height="21">

<p style="margin-left: 10">

<font face="Verdana" size="1">

<?php echo $row["blobType"]; ?>

</font>

</td>



<td width="33%" bgcolor="#FFDCA8" height="21">

<p style="margin-left: 10"><font face="Verdana" size="1">

<a href="downloadfile.php?blobId=<?php echo $row["blobId"]; ?>">

Download now

</a></font>

</td>

</tr>

<?php

}

echo "</table>";

?>


<a href="downloadfile.php?blobId=<?php echo $row["blobId"]; ?>">

Download now

</a>

#####download.php

<?php

global $blobId;

if(!is_numeric($blobId))

die("Invalid blobId specified");

// Database connection variables

$dbServer = "localhost";

$dbDatabase = "openbiblio";

$dbUser = "admin";

$dbPass = "admin";



$sConn = mysql_connect($dbServer, $dbUser, $dbPass)

or die("Couldn't connect to database server");



$dConn = mysql_select_db($dbDatabase, $sConn)

or die("Couldn't connect to database $dbDatabase");



$dbQuery = "SELECT blobType, blobData ";

$dbQuery .= "FROM myBlobs ";

$dbQuery .= "WHERE blobId = $blobId";

$result = mysql_query($dbQuery) or die("Couldn't get file list");



if(mysql_num_rows($result) == 1)

{

$fileType = @mysql_result($result, 0, "blobType");

$fileContent = @mysql_result($result, 0, "blobData");

header("Cache-Control: private");

header("Content-type: $fileType");

echo $fileContent;

}

else

{

echo "Record doesn't exist.";

}

?>

Reply With Quote
  #4  
Old April 24th, 2003, 07:42 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
jackeapen,

What version of PHP are you running? Also, do you receive any error messages, or is it simply the blank pages?
__________________
____________________________________________
Developer Shed Weekly Writer | DevArticles Forum Moderator
Build Your Own KlipFolio Klip With PHP
FrankManno.com - Under Construction
Design Interactive Group - Under Construction

Reply With Quote
  #5  
Old April 25th, 2003, 03:08 AM
jackeapen jackeapen is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 3 jackeapen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hi,
i'm using PHP 4.3.0 on Windows 98.
MySQL 3.23.47
i'm not receiving any error message. simply a blank page

Jack

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > Blobbing data with MYSQl and PHP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway