Jump to content

Shazbot!

Members
  • Posts

    41
  • Joined

  • Last visited

    Never

Everything posted by Shazbot!

  1. Hi, I had the same problem you are having of uploading an image to a mssql database and then downloading it for viewing. The issue was resolved and you can find my solution here. http://www.phpfreaks.com/forums/index.php/topic,146750.0.html The problem is the way you upload the data, there is an article in the thread that explains this. Hope this helps!
  2. ahh, that you for that. I forgot about that. I tried a different type of error and it worked.
  3. I just install PHP 5 on WinXP IIS (ISAPI) So far everything is working fine with the exception of the error handling. in the php.ini file I have the following set. display_errors = On and I have tried: error_reporting = E_ALL error_reporting = E_ALL & E_NOTICE restarted services each time but to no avail. In my test file I have <? echo "this is an error" ?> Please help. oh and the phpinfo file says the the display_error is 'ON' in both Local and Master and the error reproting is 6135 php.ini is located in the C:\Windows dir.
  4. Greetings, I need some help in with an image upload/download. I am working on a site for my wife and she needs to upload an image to a database and then download the image. php 5 with mysql 4 Problem is that when I try to display the image it shows up as garbled text (which I know is normal but I am not sure how to display it properly) The attached image is how it looks. Here is the upload code that I got from the net for uploading an image, this appears to be working. in MyPHP admin it shows the file size of the test image which looks right. mysql_select_db($database_OTH) or die( "Unable to select database"); //echo "<br />"; //echo "something else"; $fileName = $_FILES['imagefile']['name']; $tmpName = $_FILES['imagefile']['tmp_name']; $fileSize = $_FILES['imagefile']['size']; $fileType = $_FILES['imagefile']['type']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } require_once('DBConnect'); $File_SongName="Unknown"; if(isset($_POST['File_SongName'])) { $File_SongName=$_POST['File_SongName']; } $File_SongVersion="1"; if(isset($_POST['File_SongVersion'])) { $File_SongVersion=$_POST['File_SongVersion']; } $File_Uploaded_By=$_SESSION['FULLNAME']; $TimeStamp=date('M-d-Y')." ".date('h:i:s A'); echo $_SESSION['FULLNAME']; $query = "INSERT INTO TableName(File_Name, File_Size , File_Type , File_Contents, File_Uploaded_By, File_SongName, File_SongVersion, File_Date_Uploaded) ". "VALUES ('$fileName', $fileSize, '$fileType', '$content', '".$_SESSION['FULLNAME']."', '$File_SongName', '$File_SongVersion', '$TimeStamp')"; mysql_query($query) or die('Error, query failed'); echo "<br>File $fileName uploaded<br>"; Here is the code to display the data through a download page: mysql_select_db($database_OTH) or die( "Unable to select database"); $query="SELECT File_ID, File_Name, File_Size FROM TableName WHERE File_ID=32";//.$_GET['FileID']; $SQL_Query=mysql_query($query) or die('Error, query failed'); while($Results=mysql_fetch_array($SQL_Query)) { //echo $Results['File_Name']; // echo "<br />"; //echo $Results['File_Size']; //echo "<br />"; header ("Content-Type: ".$Results['File_Type']."\n"); header ("Content-disposition: attachment; filename=\"".$Results['File_Name']."\"\n"); header ("Content-Length: ".$Results['File_Size']."\n"); readfile ($Results['File_Contents']); Thank you in advance for anyone that can help me. [attachment deleted by admin]
  5. Thanks ViN86, however, they will not allow PHP to have write permissions. Thanks frost110, Not my server and I have no access to to change any settings.
  6. I have a page that runs a query that totals the sums of totals for over 5000 people. The customer can then download this information. The process takes about 2 minutes and then the results are placed in a Session Variable. This is so the user can review the information without having to run the query again. The data is very large and I have noticed that it is slowing page navigation through the Intranet site. Is there another place where I can temporarily store this large data where it won't affect page surfing?
  7. Thanks chigley , That worked to some degree, the file will download corrupted because there is no content-length listed. If I add the content-length less than 999 it works, but the file is still corrupted. If the length is greater than 999 then it will stall and not download. Not saying that the content-length is causing the corruption but there is something happing here that is causing the file to be downloaded corrupted.
  8. I have successfully uploaded adobe .pdf's to a mssql 2005 server but now I am having issues downloading the file. in IE The download window will pop-up and ask to save or download. if Download is chosen it will begin the transfer but stalls and says connect to server timeout. if I open it I get binary description of the file. in Firefox The download window appears but the OK button is disabled. I have been searching for different methods of downloading the file and here is the code that I have: The file I am testing is only 213KB $file = mssql_fetch_array($result); //obtained from http://www.phpfreaks.com/forums/index.php/topic,141818.0.html header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); header("Content-Type: application/pdf"); header("Content-Disposition: attachment; filename=$file[3]"); header("Content-Transfer-Encoding: binary"); header("Content-Length: $file[2]"); readfile("$file[0]"); /* or header("Content-type: application/pdf"); //header("Cache-Control: public, no-cache"); //header("Content-type: application/octetstream"); header("Content-length: $row[2]"); //size header("Content-Disposition: attachment; filename=$file[3]"); header("Content-Description: File Transfer"); header("Content-Transfer-Encoding: binary"); // header("Content-Description: PHP Generated Data"); //readfile($file[0]); echo $file[0]; */ thanks in advance
  9. This topic has been solved and the answer has been posted here: http://www.phpfreaks.com/forums/index.php/topic,146750.0.html The issue revolved around how MSSQL inserts binary data http://us.php.net/manual/en/function.mssql-query.php#31688 Thanks to WildBug for the assist.
  10. Wildbug, Thanks for all your help, I have been working on this problem for quite some time now and it has been a pain. The article that you posted fixed the issue. I have successfully uploaded a .jpeg and .gif and downloaded it for viewing. I would never have figured it out without your help. Thanks a lot! here is the solution that work for me: Code to upload: require_once('Connect/conn.php'); $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $datastring= file_get_contents($tmpName); $data=unpack("H*hex", $datastring); $SQL="INSERT INTO Uploaded_Files(FILE_NAME, FILE_Type, FILE_Size, FILE_PID, FILE_Content) VALUES ('$fileName', '$fileType', '$fileSize', 8231954, 0x".$data['hex'].");"; echo $SQL; mssql_query($SQL) or die('Error, query failed'); code to view: require_once('Connect/conn.php'); $SQL="SELECT File_Content, File_Type FROM Uploaded_Files WHERE FILE_PID=8231954"; $SQL_Query=mssql_query($SQL); $result = mssql_query($SQL); $row = mssql_fetch_array($result); //$row[1] header("Content-type: $row[1]"); echo $row[0]; All I need to do now is validation and I should be set to go. Thanks again!
  11. I am not familiar with MySQL but you should be able to create an OBDC DSN (control panels, administrative tools, Data Sources) to the MySQL server and connect to the Access database and use Access as the front end. Create the DB in MySQL and use that as the primary and Access as the front-end.
  12. I am assuming that this is a MSSQL server you are connecting to so you need to change the mysql to mssql. You can also try to remove the () for the column names INSERT INTO users tracknum, username, address, state, city, phone, fax, email, groupn, isdone VALUES ('$tracknum', '$username', '$address', '$state', '$city', '$phone', '$fax', '$email', '$groupn', '$isdone')") finally, if any of your fields are of type int then you will need to remove the ' ' for the values.
  13. here is the code to display the image: require_once('Connect/conn.php'); $SQL="SELECT File_Content, File_Type FROM Uploaded_Files WHERE FILE_PID=8231954"; $SQL_Query=mssql_query($SQL); $result = mssql_query($SQL); $row = mssql_fetch_array($result); header('Content-type: image/gif'); //header('Content-type: $row[1]'); I have also tried this echo $row[0]; There is only 1 record in the database that is a .gif file. In FireFox I get an outline of the image and the following error: "image cannot be display because it contains errors." The source file shows the garbled text field "GIF89a ...." In IE it just shows an image place holder.
  14. hi, I am trying to upload an image to a MSSQL 2005 database and then download it for viewing. So far it appears that it is uploading correctly but it gives me errors when I am trying to view it. I posted the help topic in the main PHP Forums http://www.phpfreaks.com/forums/index.php/topic,146750.0.html but thought that I should ask here as well if anyone has any suggestions. The datatype for the image is image. Any help would be greatly appreciated. Thanks!
  15. unfortunately that did not work and the query to test it out on the SQL Server is SELECT LEFT(40,File_Content),LEN(File_Content) FROM LEAD_Uploaded_Files; This gives me the following error: So I am assuming that the uploaded image is not being converted to a binary file. Also, the view image script is displaying this message: GIF89a and some strange characters which cannot be posted here. I am hoping some else looking at this might have another idea? Thanks in advance!
  16. I have been pondering the web, these forums and other materials trying to upload an image to a MS SQL2005 database. The database field that will hold the image is datatype: image (BLOB). So far I am able to upload the image (I think) into the database but I am not sure if this is correct or not because when I try to view it I get an image error message: here is the upload script [validation code purposely left out for testing] //code taken from: http://www.php-mysql-tutorial.com/php-mysql-upload.php require_once('Connect/conn.php'); $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $fp = fopen($tmpName, 'rb'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); $content = str_replace("'", "''", $content); //I have also tried //$content = addslashes(fread(fopen($_FILES['userfile']['tmp_name'], "rb"), $_FILES['userfile']['size'])); $SQL="INSERT INTO LEAD_Uploaded_Files(FILE_NAME, FILE_Type, FILE_Size, FILE_PID, FILE_Content) VALUES ('$fileName', '$fileType', '$fileSize', 8231954, '$content')"; mssql_query($SQL) or die('Error, query failed'); here is the code for viewing: $SQL="SELECT File_Content, File_Type FROM Uploaded_Files WHERE FILE_PID=8231954"; $SQL_Query=mssql_query($SQL); $result = mssql_query($SQL); $row = mssql_fetch_array($result); header(Content-type: $row['File_Type']); echo $row['File_Content'];
  17. Here is the code that I have. Please note that I have only been working with PHP since last Sept. Thank you for taking the time to look at this. login page session_start(); if(isset($_SESSION['SEC_LEVEL'])) { header('location:URL.php'); }//end if //some code and HTML if(isset($_POST['Submit'])) { //validate form VerifyStudent(txtName, txtPassword]); } //end if function VerifyStudent($UserName, $Password) { global $error; if($_POST['txtPosition']==1) { //student login } else { //staff login }//end if $SQL_Query=mssql_query($SQL); $User=mssql_fetch_row($SQL_Query); if(mssql_num_rows($SQL_Query)!=0) { $_SESSION['SEC_LEVEL'] = $User[0]; $_SESSION['ACCTID'] = $User[1]; $_SESSION['USER'] = $User[2]." ".$User[3]; ?> <script language="javascript"> window.location='URL/Menu.php'; </script> <?php //header('location:URL/Menu.php'); } else { array_push($error, "Invalid Username and Password"); }//end if menu.php //this is at the top of page require_once('../inc/Determine_Session.php'); Determine_Session.php //this is at the top of the page session_start(); if(!isset($_SESSION['SEC_LEVEL'])) { header('location:URL/login.php'); }//end if
  18. yep, I have session_start(); at the top of the page and it is a post back to the same page. Once validation is done it calls the function to redirect the user.
  19. Just a quick question that I hope someone here can answer. I created a login in screen that once a user is identified a Session is created for them, then I transfer them to the authorized page. However, when I use header('location:http://www.someurl.com'); to transfer them to that page the Session does not go with them. I fixed this problem by inserting a javascript that redirects them but would prefer to use php. Any help/suggesions would be helpful...thanks!
  20. I have been trying to create a drop down navigation menu for sometime now and have read a few articles which have been helpful. My problem is that they will only work if the browser window is full screen. When it is not the menu re-position's itself somewhere else on the screen, making it look very unprofessional and hard to navigate. Is there a way I can anchor the menu to an object so that when the page resizes it will remain in the correct place? Thanks in Advance for any help!
  21. I have a MSSQL 2000 database with survey data, the data field that contains the long data is varchar (8000). When I display the data it truncates the data to 255 characters including spaces. The following code is something like this: while($Results=mssql_fetch_array($SQL_Query) { echo $Results[0]."<br />"; } Is there something that I am missing?
  22. I receive a list of events through out the year. The events have an associated point value. Participants attend the events and receive points. Every semester participants can use the points to purchase items that are on auction. I would like to create a query that will calculate the total points for each participant - the points spent. table1 which contains event information, including points. table 2 contains the attendance of participants along with the program IDs. table 3 contains the points used and personal info. I can sum table 1 and table 2 to get the total points participants have earned but now I need to subtract that number by table 3 points used. I am having difficulty creating the second portion. Any advice is greatly appreciated. I can do this in PHP but want to create a stored procedure.
  23. I want to connect to a few RDS Tables that I have access to a SQL 2005 database but I can't seem to find out how to do this. I know how to do it in Access and that that works fine. I have an ODBC setup I just don't know where to start look in the SQL Server Management Studio Express. I am not the DB Administrator just the administrator of the database I am assigned to. Any suggestions on where to look is greatly appreciated. Google and MS Help did not reveal any useful information.
  24. update, The problem was a permissions issue. I tried setting the permissions on my end but the guest account only had read access. This was changed by the server admin. Thanks again for your help!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.