Jump to content

ibanez270dx

Members
  • Posts

    53
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ibanez270dx's Achievements

Member

Member (2/5)

0

Reputation

  1. Ah, thanks you guys! I enabled display_errors and, as predicted, got the error about $connection not being defined within the function. Thanks again, I appreciate the help! - Jeff
  2. Hi everyone, It's been awhile since I've coded in PHP and I can't figure out whats wrong with my code... I have a simple function to grab a field from my database and return it. I can make it work without the function, but when I implement it as a function, it breaks - no error, just a blank page. This works fine: $page = "page_about"; $sql = "SELECT body FROM " . $page . " WHERE id=1"; $result = @mysql_query($sql,$connection) or die(mysql_error()); $row = mysql_fetch_array($result); $display = $row[0]; But this does not: function grabBody($page) { $sql = "SELECT body FROM " . $page . " WHERE id=1"; $result = @mysql_query($sql,$connection) or die(mysql_error()); $row = mysql_fetch_array($result); return $row[0]; } $display = grabBody("page_about"); If anyone has any idea whats wrong, please let me know!! Thank you, - Jeff Miller
  3. thanks! I got it. Just in case anyone is having trouble with this: header("Content-Disposition: attachment; filename=\"$item_location\""); header("Content-Type: text/html"); readfile("$item_url"); Thanks again, - Jeff
  4. Hello, I have an application written in PHP that is used to securely share files, etc... however, I would like to prompt a download box when a user clicks to download a file. Currently, if the file is an accepted MIME type like .xls, .csv, .jpg, .gif, etc... it just opens the file in the browser or in the appropriate application. Is there a way I can force a download prompt? Thanks, - Jeff
  5. hello, I need to create a random 10 digit number... I can get a random number with a little snippet I found, but not the fixed length: srand ((double) microtime( )*1000000); $random_number = rand( ); echo "$random_number"; Any suggestions? Thanks, - Jeff Miller
  6. Hello, I've got a PHP app that I'd like to use hash mapping in. I haven't seen this kind of functionality in PHP before, so I was wondering if this is possible. What I'd like to do is this equilvilant to this in Ruby: myhashmap = {} myhashmap['person1'] = ['John','Smith','555-555-5555'] myhashmap['person2'] = ['John','Doe','444-444-4444'] Does anybody know if PHP has something similar? Thanks, - Jeff
  7. I just tried using an fopen type thing - it reads that it's up when the server is up, but when it's down, it just times out. Perhaps a better way to go about this is to check if my WEBrick service is running on port 4243? Is that possible?
  8. thanks, but that just gives me a 500 error... any other thoughts?
  9. Hello, I have a PHP page that basically just takes some user input (dates) and puts them into a URL which points to a WEBrick server and initializes some Ruby scripts. Everything works perfectly fine, with one exception. I want to ensure that when my WEBrick server gets kicked or is down for some reason, that PHP can realize it and act accordingly. I tried some basic PHP exception handling, but to no avail. What I have is this: try { echo "<META http-equiv=\"refresh\" content=\"0;URL=http://harrier:4243/cpa?from=$_POST[FromDate]&to=$_POST[ToDate]\">"; exit; } catch(Exception $e) { echo 'Message: ' .$e->getMessage(); } ...which leaves me with a 404 if my WEBrick server is down. Thus, I suppose I need PHP to "touch" and ensure the WEBrick server is alive before executing the META refresh tag. Can this be done? If so, how? Any and all help is appreciated! Thanks, - Jeff
  10. dude, you rule. I didn't even think of that. I automatically assumed that short tags were enabled... Thanks very much, - Jeff
  11. Hello everyone, I have a code snippet that parses a CSV file... it works fine on my personal server (Apache, PHP 4.3), but I recently installed a fresh copy of PHP 5.2.5 on a virtual server here at work and it doesn't seem to want to do it... I'm running PHP 5.2.5 on IIS v6 w/ ISAPI. I know PHP is working correctly because my test page works fine. It will not display the results in <? echo "$display" ?>. However, it will echo out when it is still in the PHP tags. It is something like this: $row = 1; $handle = fopen("test.csv", "r"); while (($data = fgetcsv($handle, 1500, ",")) !== FALSE) { if($row==1) { $row++; continue; } $num = count($data); $display .= "<tr><td><font size=2 face=arial>$data[0]</td> blah blah blah <td><font size=2 face=arial>$data[41]</td></tr>"; } fclose($handle); echo $display; // THIS WORKS ?> <? echo "$display" ?> // THIS DOESN'T WORK Any help is appreciated! Thanks, - Jeff
  12. Hello, This is probably a really simple problem, but I have a PHP page that parses a CSV file and puts it into an array, etc... Anyhow, I would like the CSV to be parsed from line 2 on, omitting line 1. My code looks like this: $handle = fopen("test.csv", "r"); while (($data = fgetcsv($handle, 1500, ",")) !== FALSE) { $num = count($data); $display .= "<tr><td>$data[0]</td><td>$data[1]</td><td>$data[2]</td><td>$data[3]</td><td>$data[4]</td></tr>"; } fclose($handle); Thanks for you help! - Jeff
  13. Hello, I'd like to post some information to another PHP page, but instead of using the form buttons, I'd like to use a plain 'ol hyperlink. This is simply for aesthetics for a project I'm working on. Anybody know? Thanks, - Jeff
×
×
  • 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.