
waddledoo
Members-
Posts
38 -
Joined
-
Last visited
Never
Everything posted by waddledoo
-
This code: <?php date_default_timezone_set('Canada/mountain'); //this is on my computer; on the webhost it is unnecessary echo date('H:i:s'); putenv('TZ=UTC'); echo "<br>"; echo date ('H:i:s'); ?> Is displaying this: 20:01:30 20:01:30 What am I doing wrong? EDIT: I don't know what the issue is on my own computer, but using the 'putenv' with the webhost works perfectly, thanks!
-
How would I change the current timezone used within a php script? The method I usually use, date_default_timezone_set() is undefined on my webhost, so I am trying to find another way.
-
The file was in public_html so I could test run the script myself. Regardless, I believe the script is running correctly now. However, it isn't sending me any messages, error or otherwise, so I will have to further test.
-
I can't exactly use commands to find out where I am, as I don't have any access to a typical command line. I'm running windows, and using my web browser to access cPanel for my website online. So, I need to type ~/public_html chmod +x (filepath)/public_html/(filename).php OR is it (filepath)/public_html chmod +x (filepath)/public_html/(filename).php or am I still way off
-
So I would enter either /public_html/(file).php OR /usr/bin/php -f /public_html/(file).php (^^or w/e the path is) EDIT: Before you replied, I tried entering '$ chmod +x file.php' and received the error /bin/sh: $: command not found
-
-
Is the line #!/usr/bin/php placed before the <?php //code ?> in the script? Also, I put the filename in the command line, and got the following error: /bin/sh: (file).php: command not found
-
I am not sure where else I could post this, so for now it's going here. I am trying to run a PHP script once every 40 minutes using cron, accessed through the cPanel of my webhost. The interface allows me to input the time and a command. The time is easy, I know how to use that part. However, I am not sure what to enter for the command exactly.
-
curl_setopt($ch,CURLOPT_FOLLOWLOCATION => true); curl_setopt($ch,CURLOPT_RETURNTRANSFER => true); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER => false); To that effect? EDIT: I get the error Parse error: parse error, unexpected T_DOUBLE_ARROW With the code. I changed the => to = with no effect. How do I properly use this function then? Second EDIT: I replaced the => with , (commas) ex/ curl_setopt($ch,CURLOPT_SSL_VERIFYPEER ,false); And I no longer get errors. My code still seems to not be running properly later in the program, and I am debugging now to find what is wrong. However, this particular post seems to be solved.
-
The URL contains the following: <api> <currentTime>2011-12-12 21:21:57</currentTime> <result> <rowset name="entries" key="refID" columns="date,refID,refTypeID,ownerName1,ownerID1,ownerName2,ownerID2,argName1,argID1,amount,balance,reason"> <row date="####-##-## ##:##:##" refID="#####" refTypeID="#####" ownerName1="#####" ownerID1="#####" ownerName2="#####" ownerID2="#####" argName1="#####" argID1="#####" amount="#####" balance="#####" reason="#####"/> <row date="####-##-## ##:##:##" refID="#####" refTypeID="#####" ownerName1="#####" ownerID1="#####" ownerName2="#####" ownerID2="#####" argName1="#####" argID1="#####" amount="#####" balance="#####" reason="#####"/> <row date="####-##-## ##:##:##" refID="#####" refTypeID="#####" ownerName1="#####" ownerID1="#####" ownerName2="#####" ownerID2="#####" argName1="#####" argID1="#####" amount="#####" balance="#####" reason="#####"/> (etc etc...) </rowset> </result> <cachedUntil>2011-12-12 21:48:57</cachedUntil> </api>
-
I am trying to get an XML file from a URL, but am instead getting errors. The code worked perfectly when executed on my own computer through a localhost server, but when executed through my webhost's server I get the errors. I am running PHP 5.3.8, and my webhost is running PHP 5.2.17, so I am assuming this may be an error between versions. $ch = curl_init($url); // Set the options for this request//This section returned a function not found error when activated on the webhost's server /*curl_setopt_array($ch, array( CURLOPT_FOLLOWLOCATION => true, // Yes, we want to follow a redirect CURLOPT_RETURNTRANSFER => true, // Yes, we want that curl_exec returns the fetched data CURLOPT_SSL_VERIFYPEER => false, // Do not verify the SSL certificate ));*/ // Fetch the data from the URL $data = curl_exec($ch); // Close the connection curl_close($ch); // Return a new SimpleXMLElement based upon the received data //The following is line 27 in the code if (!$xml = new SimpleXMLElement($data)) echo 'FAIL.'; Errors: Warning: Entity: line 1: parser error : Start tag expected, '<' not found in /home/(etc etc) on line 27 Warning: 1 in /home/(etc etc) on line 27 Warning: ^ in /home/(etc etc) on line 27 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /home/(etc etc):27 Stack trace: #0 /home/(etc etc)(27): SimpleXMLElement->__construct('1') #1 /home/(etc etc)(71): retrieveXMLdata() #2 {main} thrown in /home/(etc etc) on line 27
-
I have restarted the server several times, and my computer aswell. Under phpinfo(): Configuration File (php.ini) Path C:\Windows Loaded Configuration File C:\PHP\php.ini So it would appear yes, this is the config file; unless there it is displayed somewhere else, but disabling other extensions such as mysqli in the file I am using effects the server. Is it possible the .dll file for curl is broken? EDIT: After some further research into the cURL dll file, I found out it uses two other dll files (libeay32 and sslea32), and it was suggested that they be copied into the C:\Windows folder. After doing this, all cURL functions are running, and cURL is appearing in my phpinfo()
-
Fatal error: Call to undefined function curl_init() in C:\(etc etc...) Now I know the usual causes for a problem like this, but they are not solving anything. Yes, extension=php_curl.dll is uncommented in the php.ini file. Yes, phpinfo() displays the php.ini file I have been editing as the Loaded Configuration File. Yes, extension_dir is set correctly in my php.ini file (other extensions work). Yes, php_curl.dll exists in my ext/ folder. No, phpinfo() does not display anything about cURL, anywhere Where else can I look to possibly fix this?
-
Alright, thanks. I'll use Task Scheduler on my machine to test the code, while I figure out the webhost's system
-
Alright, the webhost does allow use of Cron. I have never used it before; is it as simple as giving it a code and telling it when to run it?
-
Is there a way of having a PHP script execute automatically every X amount of time? For example, every 15 minutes; or every week. Specifically, while running on a web host server (not my own machine).
-
I looked up the fetch functions, and after alot of trial and error I came up with: <?php session_start(); $link = mysqli_connect('#####', '#####', '#####'); $user = $_SESSION['username']; mysqli_select_db($link,"#####"); $result = mysqli_query($link,"SELECT email FROM members WHERE username= '$user' LIMIT 1"); $email = mysqli_fetch_row($result); if ($email[0]=='') {echo "<no address set>";} else {echo $email[0];} ?> It works perfectly. Thanks
-
Alright.. please explain one of these fetch functions
-
The $user is set here $user = $_SESSION['username']; I added the if statement with the die command, and it executes. It seems the user is not being set correctly EDIT: I forgot to set the database earlier in the code. This has solved the error of not returning a result, but now I get the following error: Catchable fatal error: Object of class mysqli_result could not be converted to string in C:\(etc etc...) on line 75 I tried using $display = (string)$email; echo $display; But it gives the same error.
-
<?php session_start(); $link = mysqli_connect('#####', '#####', '#####'); $user = $_SESSION['username']; $email = mysqli_query($link,"SELECT email FROM members WHERE username= '$user' LIMIT 1"); echo $email['email']; if ($email=='') {echo "<no address set>";} else {echo '$email';} ?> I figured it would be best to show the complete code. I implemented the changes you suggested, but my output remains the same (nothing).
-
I am trying to get specific data from a MySQL table but cannot seem to find a proper command. $link = mysqli_connect('#####', '########', '########'); $user = $_SESSION['username']; $email = mysqli_query($link,"select email from members where username='$user'"); echo $email; Specifically, I am trying to get the email address stored for the user specified by the session, and display that address. However, I do not get any output with the current code, and am not sure what to try next. I have tried mysqli_fetch_row() but it only returns an error.
-
I've changed the code I was using, and now use a separate php file to execute it. I also removed the onSubmit, as it didn't seem to do anything, and I don't know what it was for in the first place. <form id="f6" action="login.php" method="post" onsubmit="return weCheckForm(this)"> My new code works just fine. Thanks for the help, as I understand forms alot better now
-
Just did as you suggested with the failure echo, and it displayed FAIL Here is the full code <?php include 'dbc.php'; //another separate file that connects to the mySQL database //$username = mysql_real_escape_string($_POST['username']); //$username = $_POST['username']; //the above was commented out as I added it to the if statement if (isset($_POST['submit'])) //nothing in this statement is running { echo "SUCCESS"; $username = $_POST['username']; $md5pass = md5($_POST['password']); $sql = "SELECT id,username FROM members WHERE username = '$username' AND password = '$md5pass'"; $result = mysql_query($sql) or die (mysql_error()); $num = mysql_num_rows($result); if ( $num != 0 ) { // A matching row was found - the user is authenticated. session_start(); list($user_id,$username) = mysql_fetch_row($result); // this sets variables in the session $_SESSION['user']= $username; if (isset($_GET['ret']) && !empty($_GET['ret'])) { header("Location: $_GET[ret]"); } else { header("Location: site_002.php"); } //echo "Logged in..."; exit(); } header("Location: login.php?msg=Invalid Login"); //echo "Error:"; exit(); } else {echo "FAIL";} ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- Generated by Avanquest Technology v:8.0. For information please visit: http://www.avanquestusa.com/ --> <html lang="en"> <head> <title> Login </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Style-Type" content="text/css;"> <link rel="stylesheet" href="site_g.css" type="text/css" media="screen,projection,print"> <!--// Document Style //--> <link rel="stylesheet" href="site_006_p.css" type="text/css" media="screen,projection,print"> <!--// Page Style //--> <script src="site_g.js" type="text/javascript"></script> <!--// Document Script //--> </head> <body style="background-attachment: fixed;"> <div id="page"> <div id="e15" class="cc27"> Site Name </div> <div id="e14" class="cc28"> Login </div> <span id="e13" class="cc29"></span> <span id="e12" class="cc30"></span> <div id="e11" class="cc28"> <a href="index.php"> Home</a> </div> <div id="e10" class="cc28"> <a href="site_002.htm"> My Account</a> </div> <div id="e9" class="cc28"> <a href="site_003.htm"> Registration</a> </div> <div id="e8" class="cc28"> <a href="site_004.htm"> Page 4</a> </div> <div id="e7" class="cc31"> Login to see your account information. If you do not yet have an account, find out how to register on our <a href="site_003.htm">Registration</a> page. </div> <form id="f6" action="<?php echo $_SERVER['PHP_SELF']?>" method="post" onsubmit="return weCheckForm(this)"> <fieldset id="e6" class="cc32"> <label id="e5" class="cc33" for="e4"> Username </label> <input id="e4" class="cc34" type="text" name="username" title="username" size="23"><br> <label id="e3" class="cc33" for="e2"> Password </label> <input id="e2" class="cc34" type="password" name="password" title="password" size="23"><br> <input id="e1" class="cc35" type="submit" name="submit" value="submit"> </fieldset> </form> </div> </body> </html>
-
No its a test echo echo "SUCCESS" As it is not displaying, I can see the if statement is not executing.
-
Well, placing it under the if statement killed the error, but hasn't really solved the problem. I placed an echo into the if statement, and it isn't running. What I need is to find out how to actually get the username, password, and submit fields from the form.