Jump to content

phpchick

Members
  • Posts

    73
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

phpchick's Achievements

Member

Member (2/5)

0

Reputation

  1. Yes that worked! That was actually the first thing I tried and it didn't work (then) but now it works. so yay I must have had a typo in there when I did it the first time. Thanks Mr Marcus.
  2. I have this super simple function function getstockstats($stocksymbol) { include_once('ii-prediction-log-widget/class.yahoostock.php'); $objYahooStock = new YahooStock; $objYahooStock->addFormat("snl1d1t1cvc1p2"); $objYahooStock->addStock("$stocksymbol"); foreach( $objYahooStock->getQuotes() as $code => $stock) { echo $stock[0]; } } when I use the function, I pass it a symbol like this getstockstats("aapl"); I want this line $objYahooStock->addStock("$stocksymbol"); to receive the variable (aapl), instead, its reading it as $stocksymbol I know there is a way to exit that but I can't for the life of me figure it out because it is so hard to explain that portion. Can someone help me? I've tried wrapping it in {} like this $objYahooStock->addStock("{$stocksymbol}"); but that did not work either. Thank you!! <3
  3. The code below works echo '<script language="javascript">'; echo 'top.location.href = "/breaking-news/bsnewsstorygoeshere/";'; echo '</script>'; this also works echo '<script language="javascript">'; echo 'top.location.href = "http://anywebsite.com";'; echo '</script>'; the problem, is I have a URL listed in a url variable that can be retreived via $_GET['url'] my question is how to get that variable into the above code? I've tried echo '<script language="javascript">'; echo "top.location.href = \"$_GET['url']\";"; echo '</script>'; but that doesnt seem to work, can anyone advise?
  4. so the user is reading a story, to finish reading he has to click a link that redirects them to the signup page. <?php session_start(); $beginurl = $_SERVER['HTTP_REFERER']; $_SESSION['beginurl'] = $beginurl; echo $_SESSION['beginurl']; ?> <html> <head> </head> <body> <script type="text/javascript"><!-- location.replace("http://www.mysite.com/members/"); //--></script> </body> </html> When they get to the second page, they have to click a link that opens up a modal. this is the code that runs when they hit the register button session_start(); $beginurl = $_SESSION['beginurl']; $beginurl= (isset($_SESSION['beginurl'])) ? $_SESSION['beginurl'] : 'Error'; if( $_SESSION['status'] ='authorized') $_SESSION['$makemodal'] = 0; //sends the user to the page upon successful password credential if(!isset($_SESSION['SESS_USERID'])||(trim($_SESSION['SESS_USERID']=='admin'))) { echo '<script language="javascript">'; echo "top.location.href = $beginurl"; echo '</script>'; exit(); } Am I passing this variable correctly? and I'm not sure if the top.location.href towards the bottom is correct either, right now after I hit the register button I'm redirected to a blank page where the url is, "http://www.mysite.com/function Error() { [native code]}"
  5. problems with line 9 and 10.... I'm worried about line 9 and 10 because I took it from this example... in the example, they manually specify that if the number is greater than 1, to "throw new Exception("Value must be 1 or below");" which is why they use catch(Exception $e) later on in the script. In my code, I just use it because its what I saw in the example. But I'm not sure how to handle it otherwise?
  6. the only thing I'm worried about in my implementation is whether or not the code will continue the do-while loop if it hits the error. Can anyone verify this? do { try { $result = $wsdl->GetLastRealTimeMetalQuotes($param); $catcherror = 0; echo "it connected"; echo"\n"; } catch (Exception $e) { echo 'Message: ' .$e->getMessage(); $catcherror =1; echo "it didn't connect"; } } while ($catcherror == 1);
  7. will this work? basically I want the line that calls the web service to loop whenever it hits the fatal error. i want it to keep trying to connect until it is successful and then move on to the rest of the code. do { try { $result = $wsdl->GetLastRealTimeMetalQuotes($param); } catch (Exception $e) { echo 'Message: ' .$e->getMessage(); $catcherror =1; } } while ($catcherror != 1); //the rest of the program goes here
  8. since my error is "Fatal error: Uncaught SoapFault exception: [HTTP] Error Fetching http headers in /root/fuzzy/htmlmain9.php:126" does that mean there's nothing that can be done but manually restart it? ///////// nevermind, it's only uncaught because i didn't catch it i believe. - duh
  9. $service_header = new SoapHeader('http://www.example.com/services/', 'Header', array("Username" => "usernamegoeshere", "Password" => "passwordgoeshere", "Tracer" => "")); $wsdl = new soapclient('http://www.examples.com/f00.asmx?WSDL'); // attach SOAP header $wsdl->__setSoapHeaders(array($service_header)); // call the service: pass the parameters and name of the operation $param = array('Types' => "XAU", 'Currency' => "USD"); $result = $wsdl->GetLastRealTimeMetalQuotes($param);
  10. Not sure I understand. When this happens I just restart the code and it runs perfectly? If I can just do this everytime its okay, just not sure how to program it to do that?
  11. Here is one example of a fatal error that occurs. When this happens I just restart the code manually and it will work. i think its just temporary connection issues. Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in /root/file.php:285 Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://www.xign...', 'http://www.xign...', 1, 0) #1 [internal function]: SoapClient->__call('GetLastRealTime...', Array) #2 /root/file.php(285): SoapClient->GetLastRealTimeMetalQuotes(Array) #3 {main} thrown in <b>/root/file.php on line 285 line 285 is $result = $wsdl->GetLastRealTimeMetalQuotes($param); // this is calling a web service not sure how implement the recommended fixes in this step. when the fatal error occurs, does it spit out a value somewhere? I saw on php.net that E_ERROR (integer) is a predefined constant for fatal errors. Does this mean that I do... do { the entire code } while ( E_ERROR () =! 1 ) I'm just not familiar with the error handling syntax
  12. here's the code if other people want to use this, or learn do { $fh = fopen($ftp_path, 'w', 0, $stream_context); // Opens the file for writing and truncates it to zero length // Writes contents to the file if ( $change > 0 ) fputs($fh, "$tuff to write"); //the case if change is positive else fputs($fh, "$tuff to write"); //the case if change is negative fclose($fh); // Closes the file handle $check = file_get_contents ("$ftp_path"); echo "size of written html: "; echo strlen($check); echo "\n\n"; } while ( strlen($check) < 100 );
  13. I see the problem. the file is closed off inside the loop. but the file isn't opened inside the loop. so when it it hits that error, and executes inside the loop, it can't open up the file. Thank you kicken It looks like the program is functioning properly now.
  14. kicken: I did what you suggest and put the fclose before the get_file_contents so that it looks like this. if ($fh = fopen($ftp_path, 'w', 0, $stream_context)) { // Writes contents to the file do{ if ( $change > 0 ) fputs($fh, "stuff that goes into the remote html file"); //line 224 else fputs($fh, "stuff that goes into the remote html file"); //the case if change is negative // Closes the file handle fclose($fh); //line 231 $check = file_get_contents ("$ftp_path"); echo strlen($check); } while ( strlen($check) < 100 ); } else { die('Could not open file.'); } It runs fine until it the error occurs and the html file is less than 100 in length. then this error occurs: Warning: fputs(): 422 is not a valid stream resource in <b>/root/fuzzy/htmlmain8.php on line 224 Warning: fclose(): 422 is not a valid stream resource in <b>/root/fuzzy/htmlmain8.php</b> on line 231 size of written html: 0 line 224 is this line: fputs($fh, "stuff to be written"); //the case if change is positive and line 231 is this line: fclose($fh); //where I moved the fclose above the file_get_contents
  15. I keep getting errors that are associated with one-off and one-time occurrences. I want to tell the script to just restart itself from the beginning if it encounters any type of error, whether it by a fatal error, or any other kind. is there a way to do this?
×
×
  • 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.