Jump to content

bengaltgrs

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

bengaltgrs's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm trying to put a sql call within a function, but it does not work. If I comment out the function and just run the code straight as it is in the code below however, it works just fine. Why doesn't this code work when within a function? <?php $db = new COM("ADODB.Connection"); $dsn = "DRIVER={SQL Server}; SERVER={localhost};UID={user};PWD={pass}; DATABASE={db_name}"; $db->Open($dsn); //function GetMemberIDCreateIfNew($username, $is_admin) //{ echo "getting member id<br>"; $strquery = "SELECT member_id FROM members WHERE screen_name = 'sdasdawasdawda'"; $rs = $db->Execute($strquery); $new_member_id = ""; if(!$rs->EOF) { $new_member_id = $rs->Fields['member_id']->Value; } else { $strquery = "SELECT NewID() AS my_id"; $rs = $db->Execute($strquery); $new_member_id = $rs->Fields['my_id']->Value; } $ret_member_id = $new_member_id; echo $ret_member_id; // return $ret_member_id; //} //GetMemberIDCreateIfNew("sdasdawasdawda", "false"); $db->Close(); ?>
  2. Commenting out the 'header("Pragma: no-cache");' line seems to have fixed the problem. I still haven't tested it in any other browser though. Thank you very much for the help.
  3. Is there no solution to this aside from putting the page on an unsecure server?
  4. The file download dialog still comes up, but the filename is now 'ExportExcel_php' instead of 'extraction.xls', which is the name of the php page which is supposed to do the downloading. Upon pressing the 'Save' button, I get an error saying "Internet Explorer cannot download ExportExcel.php. Internet Explorer was not able to open this Internet site. The requested site is either unavaliable or cannot be found. Please try again later."
  5. I found the following source code for creating and downloading a file online: <?php $line1="ID\tProduct\tColor\tSales\t"; $line2="1\tPrinter\tGrey\t13\t"; $line3="2\tCD\tBlue\t15\t"; $line4="3\tDVD\tRed\t7\t"; $line5="4\tMonitor\tGreen\t4\t"; $line6="5\tTelephone\tBlack\t2\t"; $data="$line1\n$line2\n$line3\n$line4\n$line5\n$line6\n"; header("Content-type: application/x-msdownload"); header("Content-Disposition: attachment; filename=" . "extraction.xls"); header("Pragma: no-cache"); header("Expires: 0"); print "$header\n$data"; ?> This code works fine on a regular server, but when I tried to put it on my secure server I just got errors. Is there a way to make this work on a secure server? -Chris
  6. Does a PHP function exist to force a file download? I have a situation where certain people can download files, but others cannot. However, the file is just sitting on the server, so anyone could download the file if they knew the full address. I plan to use a .htaccess file to protect the directory, but at the same time I do not want people to have to type in a username and password every time they want to download a file.
  7. I tried submitting the form when the onUnload event was triggered but that didnt seem to work.  Which was odd because if I called the alert function when the onUnload even was triggered, it would go off when I refreshed the page.
  8. I have a javascript timer going on a page and I want the time to be saved if the page is refreshed.  The way it is setup now, the timer is reset when the page is refreshed.  I'm not sure if this is something I should use PHP or javascript for. Would I have to save it to a file and reload it or can I just pass it between the page?
  9. I am trying to post the value of a textarea from one page to another, using a standard form post to send it and the $_POST[] to retrieve it, then set a new textarea with that value.  It works fine except that for every instance of a newline, it will show up as a "br /", and I would rather have nothing show up at all, just the newline.  I am using "str_replace("br /", "", $Message)" to get rid of it, but that does not seem to do anything for some reason.  Is there any other way around this? (imagine the "br /"'s have brackets on them) -Chris
×
×
  • 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.