Jump to content

kicken

Gurus
  • Posts

    4,704
  • Joined

  • Last visited

  • Days Won

    179

Everything posted by kicken

  1. I've tried using APC a few times on a site I help maintain but ultimately had to disable it each time. After a few days certain pages would start being nothing but 500 errors because PHP would crash when trying to load them. Never figured out why exactly it happended but disabling APC resolved the issue. I'm not sure what would be the cause of a blank page. In my experience either it worked fine, or I got a 500 error due to the crash. Never just a blank page.
  2. If you want to see if a value exists in an array of values, then use in_array. If your array is multi-dimensional, use a foreach loop and a boolean variable.
  3. You're comparing a scalar value to an array of values there. You need to be comparing $currentTeam to one of the values from $line to determine whether it has changed or not. Considering you have $currentTeam = $line['2012team'][/code] later on, you probably want to be comparing to [ic]$line['2012team'] in that if statement.
  4. Just download and use a library such as PHPMailer or SwiftMailer. Sending mail properly via SMTP is more complicated than just opening a socket and sending a bunch of commands.
  5. That error is because of this: mysqli_stmt_bind_param($stmt, $Types, implode(',',$Values)); The arguments after $Types in mysqli_stmt_bind_params are references, which means they have to be variables, not the result of a function call. Aside from that, what you are doing is incorrect is it only passes a single value (a comma-separated string) not the three values you want. In order to pass a variable-list of parameter values, you have to use call_user_func_array to execute the function. If you search around, there are implementations showing how to do this, I've posted one on this form before somewhere. Edit: here On a side note, the inability of mysqli to support such a task nativly is one of the primary reasons why I tell people to use PDO instead and not bother with mysqli. While mysqli is an improvement over mysql_*, I find it to be sub-par and more difficult to use compared to PDO.
  6. You're not supposed to quote parameters. Not having the quotes is correct. By having them you change those ?'s from parameter placeholders into literal strings. As such, that query only contains one parameter, not three, which is why you get the mis-match error. It is possible with call_user_func_array
  7. On linux/unix you'd run ls -al from a terminal. My understanding is that OS X is similar so give that a try.
  8. Variables are case sensitive. $_session is not the same as $_SESSION (which is the proper name)
  9. There are two parts to an active session: 1) A data file stored on the server containing all the variables and their values and 2) A cookie stored on your computer which identifies which datafile to use by means of a unique hash value. Because both parts are necessary for the session to work, a session can expire in one of two ways 1) Your browser forgets the cookie or 2) The server deletes the data file. When you close your browser, you are causing the expiration via option #1. Your browser will delete it's cookie containing the hash, thus breaking the reference to the data file and killing the session. The data file will remain on the server until it gets cleaned up later by an automated process. Option #2 happens if you stay idle for an extended period of time. On the server-side, all the session files are occasionally checked to see how old they are (based on last time of access). If they were last accessed more than a set amount of time ago, they are deleted. This is what causes the session to expire if you stop surfing the website for an extended period of time, but never actually close the browser.
  10. Are there any sub-directories in that directory also? Is so those must be deleted first as well. You'll also want to check for hidden files (files starting w/ a dot ie .htaccess). Your glob pattern will not catch those hidden files. If you look at the user notes on rmdir there are numerous code samples of how to do a recursive delete of a directory, just steal one of those.
  11. Just because Dreamweaver says it is an error, doesn't mean it is. Since the syntax is relatively new, your version of Dreamweaver may just not recognize it. You need to actually run the PHP file and see if you get an error from PHP.
  12. To do this, you'd want to change the logic around a bit probably. First, find the MAX date of the entries with par <= 6 (ie, the most recent time they were not >6). Then use that to find any entries where par > 6 AND datetime > the MAX of the less than 6 values. Untested, but something like this should get you going in the right direction SELECT patients.*, addobs.*, DATE_FORMAT(addobs.datetime, '%d/%m/%Y %H:%i:%s') as dti1, (SELECT DATE_FORMAT(MIN(addobs.datetime), '%d/%m/%Y %H:%i:%s') FROM addobs WHERE addobs.datetime >= lastOkPar.lastDatetime AND addobs.part > 6 AND addobs.hidden != 'yes') as dti2 FROM addobs INNER JOIN patients ON addobs.MRN = patients.MRN LEFT JOIN ( SELECT addobs.MRN , MAX(addobs.datetime) as lastDatetime FROM addobs WHERE addobs.par <= 6 AND addobs.hidden != 'yes' GROUP BY addobs.MRN ) lastOkPar ON lastOkPar.MRN = addobs.MRN WHERE addobs.datetime = (SELECT MAX(OLAST.datetime) FROM addobs AS OLAST WHERE OLAST.MRN = patients.MRN) AND addobs.par > 6 AND NOT addobs.hidden = 'yes' AND COALESCE(patients.ward,'') != 'dc' order by addobs.par ASC
  13. Check your distro's package manager for a php odbc package and install that. You may need to edit the php.ini file to load the extension (if it doesn't do that for you).
  14. You can simplify the mysqli_real_escape_string by doing an array_map call on $_POST. Like this: function mres_cb($v){ global $link; return mysqli_real_escape_string($link, $v); } $Escaped = array_map('mres_cb', $_POST); That will escape every item in the $_POST array and save the escaped data to a new array called $Escaped. This needs to be done before your query is defined and run. Then you just change all your $_POST's in the query text to $Escaped. $query = "INSERT INTO Driver_applicants (FirstName, LastName, Applicationdate, Phone, AltPhone, DL, StreetAddress, City, State, Zip) VALUES ('{$Escaped['APPLICANT_TO_COMPLETE_FirstName']}', ... "; Unless you were specifically told by your host that you need to connect to a different port, you should not be specifying it anyway. The default port for mysql is 3306. I assumed you were attempting to use 3307 for a reason, but if not then just leave it out.
  15. Your connect line is still incorrect. Look at what I wrote above, the port goes at the end, not as the second argument. There is also the database argument to be added. mysqli_query requires two arguments, the first being the connection resource, the second being the query text. You need to update your call to match that. Add $link as the first argument. $result = mysqli_query($link, "INSERT INTO ..."); This error is caused by the second call to mysqli query that you have, which is unnecessary and can be removed. That if statement should be changed to just check the value of $result. if (!$result){ die('Error: '.mysqli_error()); } Lastly, I believe this has been mentioned before already but you really need to make sure you run all those $_POST fields used in your query through mysqli_real_escape_string. Failure to do so will cause problems with your query whenever special characters are used, and leaves you open to sql injections attacks.
  16. You use a while loop, not a do/while loop. Start with the code I gave you above and then extend it. You do not need your mysql_num_rows line or that initial $fetch_customer line. The while loop would begin just after your mysql_query call.
  17. If you check the manual for mysqli_connect, notice it has two separate parameters for the server and port. You need to split them up rather than pass them both as a string like you currently are. You can also select the database during the connect rather than after using mysqli_select_db (which you incorrectly have as mysql_select_db) $username="userhere"; $password="passhere"; $database="dbhere"; $server="iphere"; $port=3307; $link = mysqli_connect($server, $username, $password, $database, $port);
  18. You need to specify the column name to test against in the WHERE clause. The table name and column name should NOT be quoted. DELETE FROM members WHERE ID=$ID You need to define what $ID is. Based on the code, you want $_GET['id']. You will need to sanitize it to prevent sql injections, using intval will work assuming the id is a number.
  19. Are generating your output from inside the while loop's body, or after it? If you want output for each row, you need to generate that output inside the loop body (ie, where my //Do something comment is)
  20. Yes, your sort function does return something, hence the return keyword. What was being pointed out to you is that using < returns a true/false boolean, but what the function is supposed to return is a a number <0, =0, or >0. Just by luck. The code is still incorrect.
  21. You use a while loop around your mysql_fetch_array code. while ($customer = mysql_fetch_array($completed_orders)){ $requested_customers = '<a href=""> <tr> <td>'.$customer['customer_name'].'</td> <td>'.$customer['year'].'</td> <td>'.$customer['make'].'</td> <td>'.$customer['model'].'</td> <td>'.$customer['date'].'<td> </tr> </a>'; //Do something with $requested_customers } Note that your HTML is not valid either, you cannot put an <a> tag around a table row. You'd need to link each cell separately.
  22. Since you are putting the term into a regex, you'd need to escape any characters that are special to regex (unless you want the end-user to be able to use a regex). Have a look at preg_quote to solve the problem.
  23. You may have accidentally altered your user's DB permissions so that you can only SELECT, not INSERT/UPDATE/DELETE. Do some debugging to find out why those things are not working. Add some error reporting code if you don't already have it, and look at the error message that you are receiving from mysql and see what it says.
  24. The only time I've seen a permission denied error when creating a socket is when SELinux is enabled, so if you are certain it is not enabled, then I don't know of any other cause. Try running echo 0 >/selinux/enforce just to make sure, and try the script again.
  25. That is because they have different API's so you'll need to write separate code. As far as supporting the other types, you'll need to do some searching for classes which support them. I'm pretty sure there is a tar class out there, and PHP has gzip functions.
×
×
  • 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.