Re: [PHP-DB] Something Stupid
> $mysql_link = mysql_connect("myhost.domain.com","some.user","some.password " you are missing a ); > while($rows = mysql_fetch_array($myresult)); there is a ; that is not needed -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] File retrieval from DB
Beau Lebens wrote: > > Greetings all, > > I am having great difficulties with an online app that I am developing. > > To avoid issues with file permissions etc, I am saving files into a MySQL > database (soon to be PostgreSQL), which works marvellously. Along with the > contents of the file, I save the name, mime-type and size. > > When it comes time to get the files back out, I have a script that gets hit > using a URL something like "download.php?file=17" and looks like this; > > --- start script > include("conf/preferences.php"); > include("lib/generic.php"); > header("Expires: 0"); > header("Cache-Control: no-cache"); > > // Get the file from the database into a standard result set > $getSQL = "SELECT * FROM Files WHERE id='$file'"; > $fileResult = db_query($getSQL); > $theFile = db_fetch_array($fileResult); > > // If the file is intended as a download, then tell the browser to download it > // rather than display it. > if ($download == "yes") > header("Content-Disposition: attachment; filename=\"" . > $theFile["name"] . "\""); > > // Send a header telling the browser what type of file is coming and some > details > header("Content-Type: " . $theFile["type"]); > header("Content-Description: PCS Database Saved File"); > header("Content-Length: " . $theFile["size"] . ""); > > // Then pipe the file contents to the browser. > echo $theFile["contents"]; > > ?> > -- end script --- > > Now this all works perfectly well on a normal (insecure) server, the file > gets downloaded, the mime-type is correct, the filename presents itself for > download and everything in sweet. > > The problem is that the system I am developing is actually running on a > secure server, and this does NOT work in that environment. I am testing on > Internet Explorer 5 and it throws an error after you tell it you want to > download the file, saying this; > > error message > Internet Explorer cannot download ...load.php?file=17&download=yes from > www.yourserver.com. > > Internet Explorer was not abl to open this Internet site. The requested > site is either unavailable or cannot be found. > Please try again later. > end message > > Not very helpful at all. > > SO now I am at a standstill, I am completely stuck, and no one else I know > has come up with anything that can solve the problem yet - any assistance > would be fantastic - thanks all. > > Beau I know that IE is very peculiar about the order of headers that it receives, so you may want to check that. Maybe test it and get it working with NetScape first, than mess around with the order of the headers and it may start working with IE. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] select with parentID field into multidimensional array?
Well don't forget to use the order by and group by and where commands in SQL they could be quite useful in making a tree Stephen wrote: > > Im not putting the array data back intoi the db, it is just to structure > the data coming out of the db before i create a tree like structure with > it on the page > The data going into the db will always be a simple ID name parentID. Its > the neatest way to do it I can think of including using the array > structure. I am imagining it is possible to implement a way to take a > select * from table and format an array with all the data in a tree like > structure within the array with one pass of the data, then on a single > pass of the array write out the info in whatever tree like format i wish > onto my page. If I work it out Ill be sure to post it :) > > On Sun, 21 Jan 2001 [EMAIL PROTECTED] wrote: > > > Date: Sun, 21 Jan 2001 15:50:16 -0500 > > From: [EMAIL PROTECTED] > > To: [EMAIL PROTECTED] > > Subject: Re: [PHP-DB] select with parentID field into multidimensional > > array? > > > > Hi, > > > > Maybe it would be better not to use a multidimentionnal array in a db. > > You should create to additionnal columns that stores the ParentID > > of the row. > > > > It's the easiest way to do it. > > > > Also you can create another table that would translate from > > numbers to text, or just put the text. > > > > > > Stephen wrote: > > > > > > I am having most of my problems because I am trying to do this walking > > > through the data a single time, with the assumption any records parentID > > > has an ID less than the child and therefore would already be populated in > > > the array... > > > > > > On Sun, 21 Jan 2001, Stephen wrote: > > > > > > > Date: Sun, 21 Jan 2001 23:49:13 +1100 (EST) > > > > From: Stephen <[EMAIL PROTECTED]> > > > > To: [EMAIL PROTECTED] > > > > Subject: [PHP-DB] select with parentID field into multidimensional array? > > > > > > > > Hi > > > > > > > > I have a table which is set out like this > > > > > > > > ID name parentID > > > > > > > > I "select * from table" into $result. > > > > > > > > I then wish to walk through the result such that it creates a > > > > multidimensional array sorted with children under parents. Here is a basic > > > > eg. > > > > > > > > IDnameparentID > > > > 1 books 0 > > > > 2 movies 0 > > > > 3 songs 0 > > > > 4 horror 1 > > > > 5 love1 > > > > 6 horror 2 > > > > 7 love2 > > > > 8 scifi 2 > > > > 9 IT 4 > > > > > > > > etc > > > > > > > > I am trying to write a function that would then insert these into a > > > > multidimensional array as such... > > > > > > > > $array[1] = "books"; > > > > $arary[1][4] = "horror"; > > > > $array[1][4][9] = "IT"; > > > > > > > > etc, so I could pull them out into a select dropdown list nicely sorted. > > > > > > > > I am not sure how to write an array function with an unlimited number of > > > > levels. If someone could help out it would be greatly appreciated. > > > > > > > > Thanks > > > > Stephen > > > > > > > > > > > > > > > > > > > > -- > > > > PHP Database Mailing List (http://www.php.net/) > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > email: meridian at tha net > > > web: meridian.on.tha.net > > > > > > -- > > > PHP Database Mailing List (http://www.php.net/) > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > > email: meridian at tha net > web: meridian.on.tha.net > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] select with parentID field into multidimensional array?
Hi, Maybe it would be better not to use a multidimentionnal array in a db. You should create to additionnal columns that stores the ParentID of the row. It's the easiest way to do it. Also you can create another table that would translate from numbers to text, or just put the text. Stephen wrote: > > I am having most of my problems because I am trying to do this walking > through the data a single time, with the assumption any records parentID > has an ID less than the child and therefore would already be populated in > the array... > > On Sun, 21 Jan 2001, Stephen wrote: > > > Date: Sun, 21 Jan 2001 23:49:13 +1100 (EST) > > From: Stephen <[EMAIL PROTECTED]> > > To: [EMAIL PROTECTED] > > Subject: [PHP-DB] select with parentID field into multidimensional array? > > > > Hi > > > > I have a table which is set out like this > > > > ID name parentID > > > > I "select * from table" into $result. > > > > I then wish to walk through the result such that it creates a > > multidimensional array sorted with children under parents. Here is a basic > > eg. > > > > IDnameparentID > > 1 books 0 > > 2 movies 0 > > 3 songs 0 > > 4 horror 1 > > 5 love1 > > 6 horror 2 > > 7 love2 > > 8 scifi 2 > > 9 IT 4 > > > > etc > > > > I am trying to write a function that would then insert these into a > > multidimensional array as such... > > > > $array[1] = "books"; > > $arary[1][4] = "horror"; > > $array[1][4][9] = "IT"; > > > > etc, so I could pull them out into a select dropdown list nicely sorted. > > > > I am not sure how to write an array function with an unlimited number of > > levels. If someone could help out it would be greatly appreciated. > > > > Thanks > > Stephen > > > > > > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > > email: meridian at tha net > web: meridian.on.tha.net > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]