-
Posts
4,704 -
Joined
-
Last visited
-
Days Won
179
Everything posted by kicken
-
$blah is treated as a variable and the shell replaces it with that variables value (or the empty string if undefined). You need to prevent the shell from seeing it as a variable, the easiest way to do so in your case is to simply quote the URL using single-quotes rather than double-quotes.
-
The packet format is two different structures. A Word structure and the overall packet structure. The easiest thing to do would be to create PHP classes to represent these structures and have the classes pack() their own data. For integers, it would have been nice if they had specified big-endian or little-endian. It's unclear to me what format they want however it seems like maybe little-endian is what they want. If it doesn't work with little-endian try big-endian Your Word class might look like this for example: class Word { public $word; public function __construct($w){ $this->word = $w; } public function pack(){ return pack('Va*C', strlen($this->word), $this->word, 0); } }
-
Delete multiple rows with PDO and checkboxes
kicken replied to davidolson's topic in PHP Coding Help
Since you're intval'ing all the IDs, you can just drop the list into the query. There is no need to mess around with trying to make a list of parameters then bind them. $deleteIDs = array_map('intval', $_POST['sel_ids']); $deleteIDsSQL = implode(', ', $deleteIDs); $query = "DELETE FROM table_name WHERE `id` IN(".$deleteIDsSQL.")"; The intval will protect you from any SQL injection concerns. The only thing you need to ensure is that $deleteIDs contains at least one value, otherwise you'll get a syntax error. You can either check for this, or just add a value like 0 (typically unused) into the array. eg:$deleteIDs = array_map('intval', $_POST['sel_ids']) + array(0); -
If you want a variable name treated as a literal string rather than as a variable name, then escape the $. Eg: $var='foo'; echo "The value of \$var is $var\n"; would output The value of $var is foo
-
You can get a file's directory by using the __DIR__ magic constant. With this you can include a file with a path relative to that file regardless of if it is itself included else where. eg: require_once __DIR__.'/../blah.php'; If that line were located in a file saved at /var/www/htdocs/example.php then it would always include /var/www/blah.php regardless of where example.php was initially included from (or if it were run directly)
-
how to combine lots of javascript files into one?
kicken replied to toolman's topic in Javascript Help
It is a linux command, you'd run it from the shell prompt. It just joins the files together the same as if you copy/pasted them all together into a single file so if you'd rather just do that you can. If everything works as is right now, combining them should not cause any issues. -
Help with using exec to run a .bat file showing console windows
kicken replied to rcurtin's topic in PHP Coding Help
If you have apache setup as a service then it will run on it's own virtual console and not be able to interact with the desktop. The easiest way to resolve this is to switch apache so it is not a service but rather runs as your user and is started when you log in. If you run Apache as yourself rather than a service it will have access to the desktop and that should cause the windows to appear when your scripts run the program. -
If you are getting an error, you should post the exact error message you are getting. It helps people identify what the problem is. As for your problem, it stems from this line: echo "<td><a href=\"tracks.php?DiscNo=<?php echo $row["DiscNo"]; ?>\"</a></td>"; You do not open new PHP tags in order to include a variable into a string. What you do is concatenate the variable into the string using the . (dot) operator. You did this successfully on the lines before where you have the TrackNo variable. Simply use that same format for this line as well.
-
He's checking a couple of conditions, not assigning anything. MONTH(`checkout_date`) = MONTH(CURRENT_DATE - INTERVAL $month_skip_number MONTH)That checks if the MONTH portion of the date stored in checkout_date is equal to the MONTH portion of the current date less $month_skip_number months. YEAR( `checkout_date` ) = YEAR( CURRENT_DATE )This checks if the YEAR portion of the date stored in checkout_date matches the current year.
-
naming properly the primary keys, how to concatenate
kicken replied to cary1234's topic in PHP Coding Help
He just showed you it is possible. Separate the fields, and have the second be an auto-increment field. Whenever you display the fields on your reports or whatever then you can combine them into a single number. Just because you store them separately doesn't mean you have to display/use them separately. If you'll need the ability for a user to type in a number to search by it, you can either combine them for the search or split the input into separate fields. Splitting the input would be ideal so long as you have a consistent format that you can split easily (ie last 3 = auto-increment, remaining = batch)- 7 replies
-
- proper naming
- primary keys
-
(and 3 more)
Tagged with:
-
It would still take time to generate the file. Depending on what kind of setup you have, you may be able to send the file to the printer after generation rather than download it and print it locally. For one of our mass-print setups we do as mentioned by trq. Each report is generated as a PDF and the user can choose to either download/print the reports individually or select a bunch of them and download/print all. The download/print all simply merges the individual PDF's into a single large PDF and then sends it to the browser.
-
Issue with readfile() and download on at least one mobile browser
kicken replied to LLLLLLL's topic in PHP Coding Help
The device in question may be doing something odd such as a HEAD request prior to the GET request, or it may do the GET, realize it's a download when it sees the content-type and cancel that request and forward the URL to some other service which then re-issues the request. If dual requests are the cause, then you may just have to modify your script to allow them. Rather than disallow any future downloads immediately on the first request, maybe set a timestamp and any additional requests received within x seconds(or minutes) will still be allowed. When trying to debug issues like this, what I find is it is usually good to setup a log file and pepper the code with a bunch of calls which write data to the log file so you can track the scripts progression. Along with any specific variables you want to log, I usually always write the values of the $_POST, $_GET, and $_SERVER super-globals to the log as well so I can see what data is being sent to the script. With such a setup you would have been able to tell right away you were dealing with multiple-requests (as there'd be two sets of log entries) and possibly a reason why if there are any clues in one of the super globals listed. -
If you follow the established standards you can already include classes simply by referencing them with the default autoloader implementation. If you call spl_autoload_register() without giving it a function it will use a default implementation which basically just treats the namespace as a directory path. Set your include path to contain the root of your files and have a file/directory structure matching your namespace layout and PHP will automatically include them.
-
To get or set the value displayed in a text box, you use the .value property, not .innerHTML. .innerHTML is used for grabbing the HTML content between the opening and closing tags of an element. Such a thing doesn't apply to an <input> because it has no html content. document.getElementById("kmww").value=''; var postcodebeginww = document.getElementById("postcodebeginww").value;
-
You must be using some third-party administration tool which is providing this hashing option, as there is no such thing in the standard mysql stuff. To create a user and give them access to a DB in mysql you just issue a GRANT statement, eg: grant all on dbname.* to username@hostname identified by 'theirPassword'; You can type whatever value you want in for theirPassword (or leave it out entirely for no password).
-
Are you talking about the password used to access a mysql database? There is no rule regarding how long or complex the password needs to be. Most of my passwords for my development stuff are short and simple. As for recovering a password however, you don't recover it. You just change it by starting the mysqld service with grant tables disabled (ie, authentication disabled) then you update the users table with a new password. Once done restart mysqld as normal and login with the new password. The process is documented in the manual: C.5.4.1. How to Reset the Root Password
-
Happy New Year everyone! Anyone have any exciting plans for the coming year? So far my plans just include trying to get into better shape and try and get a small software business up and going with some buddies. Maybe clean my office room at some point too, boy is it getting messy! lol
-
Have a read through this page: Class Properties.
-
php curl tasks too numerous for one script
kicken replied to michaellunsford's topic in PHP Coding Help
No, curl_multi will open several connections and download the information in parallel, where as curl in a loop would do things in sequence one at a time. The script wouldn't terminate, it would keep going. You'd just set it up to run in the background, such as by using & when running it from a linux shell. You'd just setup some means of communicating with the script so you can tell it what URL's to download or any other actions you need it to do. You could write a small cron task that runs ever few minutes just to make sure the script is still alive and working, and restart it if not (a watchdog essentially). -
php curl tasks too numerous for one script
kicken replied to michaellunsford's topic in PHP Coding Help
It sounds like probably what you'll want to do is have your curl script act as a daemon process that you start up from the command line, either manually or via a helper script. That process would read the URL's it needs to fetch/parse out of a queue somewhere such as a database, memcache entry, etc. As it completes it's work it could provide status updates via a similar mechanism. Your web UI then would just inject stuff into the queue and periodically check on it's status rather than launch the curl process and wait on it. You could have a cron task that also periodically injects items into the queue for refreshing whenever necessary. As for he curl script itself, by having it running as a background daemon you don't really have to worry as much about how long it takes, the process can just run indefinitly. One way to speed it up without having to mess around with forking and multi-process issues is issue several requests at once and process the results as they come in. This is done using curl_multi_init and curl_multi_exec. There is a wrapper for this know as rolling curl that can simplify the task quite a bit. -
So after taking a few minutes to actually read a bit on the subject of AES, it would seem that the key is nothing more than a random string with a certain byte length. As such to generate your key you just need to generate a random string. The openssl function for this would be openssl_random_pseudo_bytes. If you then want to encrypt some data using your newly generated key you would use openssl_encrypt. You'll also need to generate an IV of the same size as your key string and pass that along with the key during encryption or decryption.
-
If you look at the manual page given to you, you might have noticed this function: openssl_pkey_new - Generates a new private key Use that to generate your new key. See the manual page for the specific details on how it works.
-
Need to pass additional text with $_Post var via html textarea
kicken replied to simpson_121919's topic in HTML Help
Just stick a hidden input along with the textarea and have some method of associating the two, such as the database row's ID number. <textarea name="textarea[<?php echo $databaseId; ?>]"></textarea> <input type="hidden" name="hidden[<?php echo $databaseId; ?>]" value="whatever you want"> When the user submits you'll have two arrays as input, one containing the textarea content and one containing the hidden input's content. The arrays can be matched up with the database row's ID number. -
You could also compare $_SERVER['QUERY_STRING'] to values, eg: switch ($_SERVER['QUERY_STRING']){ case 'delivery_time': //do stuff case 'something_else': //do other stuff ... }
-
Could PHP pass images via ajax to javascript?
kicken replied to D.Rattansingh's topic in PHP Coding Help
What mac_gyver was getting at is that you can just call the PHP script from the image tag directly, there is no need to save the image to a file on the server. Just have your JS add a new image tag to the DOM like so: var img = document.createElement('img'); img.src = 'generate.php?param=value¶m2=value2&etc=etc'; document.body.appendChild(img); You add whatever data the script needs to generate the graphs as URL parameters and then just have the script generate and output the image. As for the actual question "Can you pass an image back with ajax?" the answer is yes, as a data: uri. For example you might send back a json response looking like: { "status": "up" , "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAAZiS0dEAHQA/wBxbIuINwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sBFBYIBm8nX8sAAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAAAfVJREFUOMudk01oE1EUhc/MZEzSSpupTaFWMYsaNCDWQZGxS39WxZ+6KCLiRrrowpWLgujCnSLuLEQQRHEjXbkRpRQpKW6kBJQYKja1xJBmZkrHmTdvZt78uJBIaOMieavH5dyPc899D+jyTBauHAYArlvAbXOGmg2rzHfTfKN0/Wl8bzxBdPKmYweXP15KHpRHSMCCYG5fXox1CkhKiSVGGaet6R8AoKMRLi5MHANw0lIJ7C17CgA6chBFWHRND3Tb/vZu4r3V1sHYo7EL7ZrPz5+bdgw6SA0KarhTzfq/EI/ey/UHflAhqiWlR9M3i7PFl62A8efjHs/zYhiE28u3lqVmnQeA7Gz2tFbRtfVPPyWjZkGvbL2Qn8hnmiIlr7wmDUukBgWj7G4r+G8GEXqZzQSPMIR+BH094MSe2JKSV4aiMIK+pl/jBR48ZV7pQWmuFcADwOrD1cWh7KAycCgV+q4Px3RR+1IX1O/qhlH7XbBUwlHTBTjM78xGaF70gv4rM5l5C2CaaITzvQBEtfdYGklHERCyIEodkE7VF+pBK2DXS5Qfy0c2Ple/aj80AeAQS8QQT4qQMqli9Vn1xE79rjWu3FkpjxwfHu0b7vOBCL7jw7Fc9Az0Xm233v/+hdz93P7NcqPAHD+e7E+UN1/Vz7bT/QE+w9rOepXa4QAAAABJRU5ErkJggg==" } Doing something like that takes up a lot of unnecessary bandwidth however as data URI's get pretty big. You're better off going the dynamic image route as mentioned previously.