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 August 25th, 2003, 09:19 AM
tmbecker32 tmbecker32 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 4 tmbecker32 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
PHP Mysql Error

I have gotten my files to upload to but then I cannot get them to download correctly using php.

I get this error
Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\wwwroot\cvsvision\downloadfile.php:3) in C:\Inetpub\wwwroot\cvsvision\downloadfile.php on line 31


and then a bunch of code. help!!!

Reply With Quote
  #2  
Old August 25th, 2003, 10:05 AM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
Please post the parts of code that are a problem.
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #3  
Old August 25th, 2003, 10:36 AM
tmbecker32 tmbecker32 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 4 tmbecker32 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
this is the file that writes it to the database
<?php require_once('Connections/news.php'); ?>
<?php
mysql_select_db($database_news, $news);
$query_Recordset1 = "SELECT * FROM market_reports";
$Recordset1 = mysql_query($query_Recordset1, $news) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
//GrabFile.php: Takes the details<br>
// of the new file posted as part of the form and adds it to the database db_news to the market reports table
global $Report_Type;
global $Date;
global $fileUpload;
global $fileUpload_name;
global $fileUpload_size;
global $fileUpload_type;

echo $HTTP_POST_VARS["frmUploadFile"];

// Make sure both a description and

// file have been entered

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

die("You must enter all information");

$fileHandle = fopen($fileUpload, "rb"); // opens up the uploaded file and reads it into the database
$fileContent = fread($fileHandle, $fileUpload_size);
$fileContent = addslashes($fileContent);//escapes any apostrophises and Double quotes

$dbQuery = "INSERT INTO market_reports VALUES ";

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

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


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='blobtry.php'>Add Another File</a>";

?>

</body>

-------------------------------

Here is the file that tries to download it

<?php require_once('Connections/news.php'); ?>

<?php
mysql_select_db($database_news, $news);
$query_downloadBlob = "SELECT * FROM market_reports";
$downloadBlob = mysql_query($query_downloadBlob, $news) or die(mysql_error());
$row_downloadBlob = mysql_fetch_assoc($downloadBlob);
$totalRows_downloadBlob = mysql_num_rows($downloadBlob);
?>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<?PHP global $blobId;
$dbQuery = "SELECT blobType, blobData ";
$dbQuery .= "FROM market_reports ";
$dbQuery .= "WHERE blobId = $blobId";
$result = mysql_query($dbQuery) or die("Couldn't get file list");
$fileType = @mysql_result($result, 0, "blobType");
$fileContent = @mysql_result($result, 0, "blobData");
if(mysql_num_rows($result)==1)
{
header(content-type: $fileType);
echo $fileContent;
}

else

{

echo "Record doesn't exist.";

}

?>
<body>

Reply With Quote
  #4  
Old August 25th, 2003, 11:01 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
You're trying to echo conflicting content-types. When you print HTML out to the screen, a Content-type: text/html header is sent by default. You're doing that and then also sending a header for the file type being downloaded. You have to pick one or the other and send only the headers you need to send. My guess is that you'll want to remove the HTML output.

Reply With Quote
  #5  
Old August 25th, 2003, 11:29 AM
tmbecker32 tmbecker32 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 4 tmbecker32 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Here is the download file I have now.

<?php require_once('Connections/news.php'); ?>

<?php
mysql_select_db($database_news, $news);
$query_downloadBlob = "SELECT * FROM market_reports";
$downloadBlob = mysql_query($query_downloadBlob, $news) or die(mysql_error());
$row_downloadBlob = mysql_fetch_assoc($downloadBlob);
$totalRows_downloadBlob = mysql_num_rows($downloadBlob);
?>

<?PHP global $blobId;
$dbQuery = "SELECT blobType, blobData ";
$dbQuery .= "FROM market_reports ";
$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("Content-type: $fileType");
echo $fileContent;
}

else { echo "Record doesn't exist."; }?>


<?php
mysql_free_result($downloadBlob);
?>
---------

I am still getting that error. Is there anything else I should do???

Reply With Quote
  #6  
Old August 25th, 2003, 12:06 PM
tmbecker32 tmbecker32 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 4 tmbecker32 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Basically how do I get rid of the default html/text header????

Reply With Quote
  #7  
Old August 25th, 2003, 12:44 PM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
Why do you keep opening and closing your php scripts when there is no html output in between them?

You are outputting blank lines each time you do this.

You need to either keep all your php code in the same <?php block or take the space out from between each block of code.

Reply With Quote
  #8  
Old August 25th, 2003, 01:06 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
And, just to expand laidbak's comment and make its explanation a little more explicit, blank lines equal HTML output that's keeping your headers from working properly. If you've got extra lines above, below, or between your PHP markers, you're likely to have problems.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > PHP Mysql Error


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 3 hosted by Hostway