Jump to content

Raconteur

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Raconteur's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi gang, This is driving me nuts, and I am hoping SOMEONE can shed some light on it. I am getting a "Cannot redeclare..." error whenever I reload a page. The page runs fine the first time through, but if I hit the Refresh/Reload button, I get the error. Files are very simple. I have test.php, which has an require_once "DBI.php" in it. The DBI.php connects to a MSSQL table, and defines a function, getColumns($table). The function is nothing more that a query string and a call to MSSQL_QUERY, and a return $result. Actually... here is the code for both files: test.php require_once "DBI.php"; $table = "test"; $cols = getColumns($table); DBI.php $conn = MSSQL_CONNECT("localhost", "<username>", "<password>"); if (!$conn) { echo "NO CONNECTION!"; die; } else { MSSQL_SELECT_DB("Northwind", $conn); } function getColumns($table) { $sql = "SELECT column_name FROM information_schema.columns WHERE table_name = '$table'"; $result = MSSQL_QUERY($sql); return $result; } I load the page, everything looks good, but if I hit refresh, the error gets thrown. Could this be a .INI file issue? Or am I missing something? Interestingly, if I issue an iisreset from the command line, the error goes away, until I refresh. I am running WinXP Pro, IE7, PHP5.2.1 and SQL Server 2K. Thanks for any help! Chris
  2. Ok, so testing the PHP script from the command line seems to work just fine, so it is the browser caching the result. Now my problem is, the AJAX code is being call to populate a little DIV in a small box on the main page, so how do I install additional headers if the page already exists?  That is the part I am not getting. Thanks!
  3. Hi Vikas, Thanks for the info.  Seems easy to just add the code and see if the problem is fixed.  Can it be added to the HTML HEAD directly?  I already have: [code] <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Expires" CONTENT="-1"> [/code] Will that not work? Cheers, Chris
  4. Hi gang, I am either a bumbling idiot or am doing something so simply wrong that I just cannot see it... I have a script (PHP) that is using an AJAX call to pull a random row out of the DB, using: [code] SELECT * FROM <table> WHERE active=1 ORDER BY rand() LIMIT 1 [/code] If I run that in a query editor against the DB it works as expected.  A different, random result on each call. However, when I run it from my code, I ALWAYS get the same result.  The AJAX calls a server-side script which looks like this: [code] include_once("ssDataBroker.php"); $ssDB = new SSDataBroker(); $ss = $ssDB->retrieveRandomSS(); $ssString = implode("~", $ss); echo $ssString; [/code] The code in the SSDataBroker object for #retrieveRandomSS() looks like this: [code] $sql = "SELECT * FROM aia_cms_success_stories WHERE active=1 ORDER BY rand() LIMIT 1"; $results = MYSQL_UNBUFFERED_QUERY($sql); return MYSQL_FETCH_ARRAY($results, MYSQL_ASSOC); [/code] In this code I have tried using MYSQL_QUERY, and thought that the result was being cached, so I switched to MYSQL_UNBUFFERED_QUERY, but that did not help.  I have also tried closing the connection to the DB and reopening it on every call, but that did not help either. The problem seems to be in the PHP code itself, since the query works just fine when run against the DB, but I cannot see what it wrong. Can someone out there help? Thanks in advance! Chris
  5. Hi Matt, Thanks for the reply.  Not sure I am understanding what you are asking. I have this in a template that is used by the PHP page serving the CMS:  <img src="images/pix.gif" id="ssImage" /> When I parse the result string of the query in the JS function that handles that, I am doing:  document.findElementById("ssImage").src = results[3] where results[3] contains the binary data of the image. This just seems wrong, since the src property is looking for a file name, and it doesn't seem to be working. Does that make sense, and help answer your question? Cheers, Chris
  6. Hi all, I am having a tough time finding a solution to a specific problem.  I have a tiny CMS used to manage success stories.  The success stories include name, blurb, and an image.  The admin screen is laid out with the input/edit section at the top, and the list of success stories in a table below.  Typical list/detail scenario where the user clicks on a row in the table and via AJAX the data is displayed in the form at the top. Now, the problem is, I want to be able to display the actual image when that happens.  I have the IMG tag in the page template, but I cannot get the image to actually display.  Note that the actual binary data is stored in a BLOB in the DB.  I have tried setting the src property of the Image object associated with the IMG tag, but that doesn't seem to work.  I can't imagine that this is not possible, and am hopefully just overlooking something simple. My link on each item in the list calls a JavaScript function which creates and opens the XMLHTTP request to call the PHP code to fetch the requested data.  The data is fed back in a "~" delimited string, and the JavaScript function that handles the result breaks it apart and stuffs it into the appropriate objects on the screen.  Is there some way to do this on the client, or is this one of those cases where AJAX won't work and I have to do the round-trip and have to code it all in PHP? I realize this question is really walking the edge of being PHP related, but I alway get great help here, and figured a PHP person would have a far better idea of how to do this.  Thanks for tolerating a questionable question!  ;) Can anyone shed any light on this for me? Thanks in advance! Chris
  7. Problem is it still uploads the file under the PHP script which marks it owned by "nobody". Perl (CGI in general) run under a user account, rather than "nobody", so the Perl solution is working... I just need to integrate it into my PHP. Any suggestions there? [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /]
  8. Ahhh... now things are becoming clearer. That bit of upload code is exactly my problem. I have a CMS that allows users to upload pics for use on the site, however, by using that mechanism of uploading, the images are owned by the PHP process owner "nobody". That means that we cannot do anything with the files once they are up there (can't move them, delete them, etc.). So, I thought if I FTP'd them up, they would be owned by the FTP user. But the FTP base is doing the same thing? I guess I will have to resort to Perl, which from what I understand, will run as the user. Thanks a ton! Chris
  9. Hi there, Thanks for the responses. SA, yes, the file definitely exists. wildteen88, you are correct, the script is running on a server running Unix, and I am trying to access a file on my local machine. But if that is not possible, how can you FTP something? Wouldn't make sense if you couldn't upload from a local source... Am I missing something here? Cheers, Chris
  10. Hi all, I am trying to do a simple fopen [code]fopen('c:\temp\pic.gif', 'r')[/code] but it keeps failing with [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: fopen(c:/temp/pic.gif): failed to open stream: No such file or directory in /home/find6/public_html/ftp.class.php on line 258[/quote] Is there some well-known but poorly documented trick to making fopen work? I have scoured PHP.NET and cannot find anything that seems to help. Any assistance GREATLY appreciated! Cheers, Chris
  11. Does ANYONE have anything to offer on this? Please...?
  12. Hi gang, I am hoping someone can point me in the right direction here... I have a CMS that allows us to upload images to be shown on our site, which uses the PHP file upload mechanism (input field of type "file" and the ENCTYPE="multipart/form-data" in the form tag). This works wonderfully, with one exception. The script runs on the Unix server as "nobody", which means whenever I want to modify, move, download or delete the file, I cannot because I FTP in under a real user. So, I thought, well, I will just bypass the PHP form upload stuff, and use the basic PHP FTP stuff. But I cannot get that to work either... Here is my code for that: [a href=\"http://pastebin.com/712159\" target=\"_blank\"]http://pastebin.com/712159[/a] Using the ftp_put method, everything seems to play well, but I get the "FTP upload has failed!" error after checking the value of $upload. I thought maybe this was because the $localFilePath was just the name of the file, so I hard coded the path and file name, but got the same error. Then I tried ftp_fput, but got errors trying to open the file with fopen... Basically, all I need to do is find a way to upload files to our site and make the owner an actual user, rather than "nobody" as PHP scripts run as. Any help out there? Thanks a million... this is driving me nuts! Cheers, 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.