define() vs const
Pretty straightforward question: In PHP, do you prefer to do (and why): define('FOO', 1); OR const FOO = 1; Also, the code is NOT in a class. Thanks. ...
Pretty straightforward question: In PHP, do you prefer to do (and why): define('FOO', 1); OR const FOO = 1; Also, the code is NOT in a class. Thanks. ...
I have a web application that accepts file uploads of up to 4 MB. The server side script is PHP and web server is NGINX. Many users have requested to increase this limit drastically to allow upload of video etc. However there seems to be no easy solution for this problem with PHP. First, on the client side I am looking for something tha...
I'm brand new to PHP & MySQL, and one function I'm creating needs to access a large table or database. I've created the database and it's currently in a MySQL table, which I'm accessing with no problem. The table is 11,000 rows in length, with 8 columns (all text less than 8 characters long) - it's static, and will never change. Without ...
Hello, I need to generate a string of incrementing dates, something like this: (year, month, day, hour, minute) 2010, 2, 12, 11, 30 2010, 2, 12, 11, 31 etc What would be the best way of doing this? I may want to generate up to 1000 lines like this ...
Not sure if I can do it this way. I want to get current snapshot of the database and send it via FTP Server, both of this functionality should be implemented in PHP scripts. Here are the steps I am thinking on right now. In my php scripts(basically am extending an PDO into my Dao class and then preparing the query), $qry = SELECT *...
I'm trying to remove a form element generated through Ajax calls, but when I submit the form and var_dump the POST request, I can still see the form field key=>value. I need to be able to completely remove the field through jQuery in order to validate correctly. ...
I'm trying to enter values into a database table using a form and a PHP function. The PHP seems to be fine as the SQL statement it creates looks okay, but the database always throws up an error. This is the SQL statement that my code has generated (with arbitrary values): INSERT INTO Iteminfo ('itemName', 'itemSeller', 'itemCategory', '...
Okay all, I have a form that I want users to fill out. When They click submit, I want the contents of this form to be put into a message, and I want the contents to be added to an excel file. Then I want the message that is sent to the recipient to have an attachment of that excel file. You will see partial mime code, I have no Idea how ...
Trying to write a couple of functions that will encrypt or decrypt a file and am using the class found here to try and accomplish this: http://www.itnewb.com/v/PHP-Encryption-Decryption-Using-the-MCrypt-Library-libmcrypt The encryption function below seems to work, in that it appears to encrypt the file and place it in the intended d...
I'm having a little trouble controlling page-specific block display in Drupal... My URL's will be of this typical structure: http://www.mysite.co.uk/section-name/sub-page/sub-sub-page The 'section-name' will effectively be fixed, but there will be many sub-pages (far too many to explicitly reference). I need to somehow control block ...
I'm trying to set up a feature where after accessing a wepage, the user is not allowed to return until they have been away for x minuets. It's on a login system, so I don't need to worry about IPs etc. What I had in mind was as following: User accesses page; current time (of access) is logged (in database?). User tries to return to pag...
Hi, Today I run into some oddity with PHP, which I fail find a proper explanation for in the documentation. Consider the following code: <?php echo $_GET['t']. PHP_EOL; ?> The code is simple - it takes a single t parameter on the url and outputs it back. So if you call it with test.php?t=%5Ca (%5c is a '\'), I expected to see: \a ...
Example: $arr = array('apple'=>'sweet','grapefruit'=>'bitter','pear'=>'tasty','banana'=>'yellow'); I want to switch the positions of grapefruit and pear, so the array will become 'apple'=>'sweet','pear'=>'tasty','grapefruit'=>'bitter','banana'=>'yellow') I know the keys and values of the elements I want to switch, is there an eas...
Hi I want to write a php script which updates svn working directory I tried with below code , but it does not work.I guess because the USER for php script is "apache" but for svn update it needs to be "homeuser" putenv("USERNAME=homeuser"); putenv("HOME=/home/homeuser"); exec("svn update /home/homeuser/path/to/working/...
The script I'm using is if($profile['username'] == $user['username']) { $db->query("UPDATE users SET newcomments = 0 WHERE username = '$user[username]'"); echo "This is a test"; } (Note that $db->query is exactly the same as mysql_query) For some very odd reason, the MySQL query is being performed even if the defined conditio...
Hi Everyone, I have written a PHP script which connects to my Gmail account and loops messages inside the "INBOX" folder. However, I want to learn the "labels" of each message that exist in the INBOX folder. In other words, I want to learn which other IMAP folder does each message in the inbox exist? In this way, I am planning to write ...
I have a backup created of my mysql database (vbulletin forum v3.8) everyday. It's about 360mb in size. It's stored as one text file in a secure folder. I'm thinking of getting another server, through a different host, and somehow automatically transferring the backup to my second server every day. Any ideas on how I could automate th...
I have a table of data that is searchable and sortable, but likely to produce hundreds or thousands of results for broad searches. Assuming the user searches for "foo" and sorts the foos in descending price order I'd like to show a quick-jump select menu like so: <option value="1">Page 1 ($25,000,000 - $1,625,000)</option> <option value...
Hi, I am having a problem, pound signs and single quotes are being read from a file as � My code is below: $fh = fopen($_FILES['importFile']['tmp_name'], "r"); $contents = fread($fh, filesize($_FILES['importFile']['tmp_name'])); var_dump($contents); Does anybody know how to fix this issue. I know its an encoding issue but unsure as...
Hi! I've got a huge problem. I made a special ID for the things in our webpage. Let's see an example: H0059 - this is the special ID called registration number. The last two chars are the things' id. I'd like to cut off the useless characters, to get the real ID, what means strip the first char, and all the 0s before any other number...