-
Posts
4,704 -
Joined
-
Last visited
-
Days Won
179
Everything posted by kicken
-
That generates an invalid query. You would need to quote the $page variable just like you did the raw string: $issues = mysqli_query($connection, "call page_issues('$page')"); You should run $page through an escape process to make sure any bad characters get escaped. Alternatively, a better method would be to use prepared statements and query parameters. I don't use mysqli so the below is just a best guess at the proper code: $stmt = mysqli_prepare($connection, 'call page_issues(?)'); mysqli_stmt_bind_param($stmt, 's', $page); mysqli_stmt_execute($stmt); mysqli_stmt_store_result($stmt); $result = mysqli_get_result($stmt); var_dump(mysqli_fetch_all($result));
-
An image submit button generates x/y values rather than just it's name, so you have to test for $_POST['submit_x'] and $_POST['submit_y']. Alternatively you could change your test to some other field, or change the submit button to use a <button> tag. <button name="submit"><img src="images/enter_inactive.png"></button> If desired, you can use CSS to remove the button's default styling so you only see the image.
- 9 replies
-
- form
- age verification
-
(and 2 more)
Tagged with:
-
He's not trying to find "the most recent par score > 6", he's trying to find entries "who's most recent entry has par > 6". Entry 2 should not qualify because their most recent par score is 5.
-
Use a CASE statement and SUM. For example: SELECT someField , SUM(CASE WHEN email='Yes' THEN 1 ELSE 0 END) as emailCount , SUM(CASE WHEN sms='Yes' THEN 1 ELSE 0 END) as smsCount , SUM(CASE WHEN web='Yes' THEN 1 ELSE 0 END) as webCount FROM table WHERE name LIKE '%test%' GROUP BY someField
-
So the city part and the title part are variable, the rest is static. That makes it easy, just use the appropriate variables as keys: $structure[0][cards][0][info][$type][$property] You must already have some code to determine that you want 'city' and 'title'. Just use that same bit of code but store the results into the variables. Then to read the value, use those variables as keys.
-
I don't know the twitter api at all, but based on your code sample you appear to be making a separate request to the twitter service for every row that your query returns. If your query returns say 20 rows, that's 20 individual requests. Assuming twitter is running smooth and answers each request in say 60ms time that's 1.2 seconds just talking with twitter + whatever time it takes to do on your end for processing. The more results you have, or the slower twitter is at responding, the slower the page load is going to be. What you should do is find out from the API docs (or someone) whether it is possible to get the information for ALL of the twitter users you need in just one call. If that is not possible there may be alternative ways to accomplish what you are doing, such as an async method like mentioned above.
- 15 replies
-
- php
- twitterapi
-
(and 1 more)
Tagged with:
-
You can't just load any .so file into PHP and have it work. The only .so files you can load into PHP are PHP Extensions. Given what you've written so far, you don't appear to be trying to load an extension, so you cannot load the file into PHP.
-
As far as Mysql goes, an IP is just another piece of data, and it doesn't do anything special with it. You'd store it into a varchar or a binary column type. To insert it into mysql you do the same as you would any other piece of data. Create an execute an INSERT query with the IP as one of the column's values.
-
Then you're doing something to add those commas, such as running the number through number_format before saving it or after retrieving it. Check the DB value using something like phpMyAdmin, mysql cli tool or Workbench to see what the value of the column really is. If you have commas in the number there then that also means your storing the value in the wrong field type because an INT field (which you should be using for numbers) wouldn't allow such a value to be stored. On a side note, since your storing a date you should be using a DATETIME or TIMESTAMP column type and putting the value into the db using the YYYY-MM-DD HH:mm:ss format, rather than using an INT and a unix timestamp.
-
If you're on a windows server, then none of this chmod stuff really applies. Windows uses ACL for it's permission system which means you just add both your user and the server's user to the directory in question with the appropriate permissions.
-
You need to configure various SSL* options, none of which you have done in your posted file. Pick one of the tutorials you say you have tried and follow the steps it tells you to do. If things do not work then post back with the url of the tutorial as well as the contents of the relevant files. Paste the contents of the files into your post between tags, not in an external paste site.
-
What commas? There are no commas in either of those variables with the code given. For what it's worth also, that code is the same as just doing $Timestamp = time(); There is no need for the gmdate() and strtotime() functions.
-
When it comes to mass mailing, what you should do is store the information you need to email into a DB, then have a background process do the emailing. That way the user doesn't have to sit and wait on a loading page for a long time while the emails go out. You can also disable timeouts on the background process so that it can run for as long as needed. Also, check your mailer library to see if it is reusing the same connection or opening a new connection to the server for every email it sends. One library I had used in the past did one connection per email. Changing it to reuse the same connection cut the run time nearly in half.
-
Just wrap the bit of code that generates and saves the coupon code in a loop. Then run your export after everything is generated. $limit = $_SERVER['argv'][1]; for ($i=0; $i<$limit; $i++){ $code = random_string(); $sql = 'INSERT INTO ...'; $query = mysql_query($sql); ... } //Then export $sql = 'SELECT ...'; $result2 = mysql_query($sql); ...
-
How are you generating the $str variable? How do you know that you want to replace ':title' with the value at '$structure[0][cards][0][info][city][title]' rather than say some other index in the structure array?
-
Werid csv encoding, strlen returns twice length it should
kicken replied to NeilWalden's topic in PHP Coding Help
It's probably in an encoding such as UCS-2 which uses two bytes per character. You can use iconv or mb_convert_encoding to change it to a different encoding. -
Read up about how to do Responsive Web Design.
-
I gather your "basic concepts of programing" are Algorithms and Problem Solving. PHP provides just as much ability to learn those aspects as any other language does. Sure it may provide a lot of hand extensions or libraries that will handle a lot of those things for you, but so do most other languages at this point. If someone is not learning these concepts with PHP it is not because PHP sucks and they would do better with something like C. It's because they are lazy and don't really want to program at all. If they were starting with something like C rather than PHP they probably would have just given up entirely rather than take the initiative to learn these "basic concepts." PHP is great for a first language. It is easy to use, simple to setup, provides instant feedback by just having to refresh vs re-compile and run, has very good error reporting and recovery from errors, and a syntax that is similar to a number of other language. For someone who has never programmed before, the above environment is perfect setup since they get good feedback about what they did wrong instantly, and their time spent learning the syntax will apply more easily to other languages.
-
How to create a message board signature generator
kicken replied to mthompson's topic in PHP Coding Help
You'd use the GD Library to do the image stuff. The script would basically go something like this: 1) Create GD resource from your background image (see imagecreatefrom* functions) 2) Generate the text you want to put on the image using the $_GET variables for the different fields (string var) 3) Write the text onto the GD resource (see imagettftext) 4) Output the image in the desired format (see imagepng, imagejpeg, etc functions) -
Is there a good/stable hosting service somewhere?
kicken replied to lisawebs's topic in Applications
There are tons of hosts out there at a wide range of prices. There is a whole thread full of suggestions over in the Miscellaneous forum. Read through it and take your pick. -
You can't compare a JS variable to a PHP variable during the execution of your PHP script. That is just the way it is, learn to deal with it. You can export a PHP variable into Javascript and compare with javascript, but not the reverse. If you need the value of a JS variable in your PHP script then you either have to include it somehow in the request, or do a separate request using ajax or similar.
-
They does it matter if you end up with a "useless" windows key. A keyboard without one is not likely to be any cheaper than one with one. Having a key that does nothing won't screw anything up. Buy a keyboard you like the layout/form-factor of rather than fixating on a silly key. Pop the key off if bothers you that much.
-
Just set the src according to that condition. Also, use tags when you post your code. $picurl = $row['stock']==0?'/images/soldout.png':$row['picurl']; echo '<img src="'.$picurl.'">'; That will set picurl to '/images/soldout.png' if the stock is zero, otherwise it will set it to whatever comes from the DB. Then you use $picurl as the source for the image.
-
Most of the time things like this are handled by using exec() to execute an external application with the proper arguments to do the conversion you want. The ffmpeg CLI tool is offered on some hosts and is fairly easy to use. So what you'd do is create a PHP script that lets you specify all the different options you need and then just executes the fmpeg tool to do the actual conversion. Once the conversion is done you can have your PHP script do any further processing that may be necessary. Trying to process the video data within a pure-php solution would likely be painfully slow, if it's possible at all. That is why these types of tasks are done via C either as a PHP extension (if available) or an external CLI tool.
-
You'd need to ensure your PHP file is also saved in UTF-8 for something like that to work. str_replace is not character-set aware, it just does a binary replace so the character sets of all the arguments would have to match for it to work properly.