Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. The variable you are putting into your query statement IS NOT the output from your use of mysql_real_escape_string. It is the ORIGINAL $_POST variable.
  2. array_flip
  3. The reason for the need to refresh the page to get the 'updated' settings to be displayed, is because the logic on the page is out of order. The code gets the settings and produces the form first, then it updates any changes. Since programming does not involve magic or the ability to go back in time, the current code cannot display the updated information unless it is rewritten to process the form submission first, then get and display the settings second.
  4. What symptom do you see in front of you when you try it? Without knowing that, it would be impossible for anyone here to actually help you with what your code and your data is doing on your server. What debugging have you done to pin down what execution path your code is taking? Finding at what point your code and data is dong what you expect and at what point it is not (I can guarantee that the problem lies between those two points) is how you debug code that doesn't work. As already mentioned by Alexv, you should have php's error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that php will help you by reporting and displaying all the errors it detects. The original error that was pointed out is a fatal parse error and php's error_reporting/display_errors would have pointed out an error in that line of code. You will save a TON of time and if you are in a classroom situation, the development system you are using should already be set up this way and/or you instructor should have made a point of the importance of setting the php error reporting settings during development, before you ever tried running your first .php script.
  5. Your code outputs - Name is: Bach If you didn't get anything, either your actual code contains a php error, your opening php tag isn't a full <?php tag, php isn't installed and running on your server, or you didn't browse to the URL of your page in your browser. What does a 'view source' of the page in your browser show? What URL did you browse to (it should be something like http://localhost/your_file.php on your local development system)?
  6. By 'it' I assume you mean the browser (browsers request and render the media files on a web page.) Are you using a valid web accessible URL to the splash image file in the HTML markup on your page? You can either use a fully qualified URL - http://somedomain/some_path/some_file.ext (the browser uses the URL directly) or a domain root relative URL - /some_path/some_file.ext (the browser appends the given URL to the domain of the current page) or a (page) relative URL - ../some_path/some_file.ext (the browser appends the given URL to the URL of the current page.) Don't confuse URL's (that browsers use to make HTTP requests for files) with file system paths (that php uses to include files on the server.)
  7. There's probably a half-dozen different things that could cause that symptom, the most likely being that the session start statements don't work. You need to be developing and debugging any php code on a system with php's error_reporting set to E_ALL and display_errors set to ON so that php will report and display all the errors it detects.
  8. You need to pick one that you are most familiar with and which has the features you need and troubleshoot why it does not work for you on your server. There is likely some common problem with your server or with even something your programming editor or FTP program does that is causing all of them to not work. If you want help with a script, post it in the forum's [color=red]...[/color] bbcode tags. Edit: Along with a specific statement of any symptoms or errors you got when you tried it. P.S. A significant portion of the php code posted around on the Internet (anyone can became an Author nowadays) is either out of date or was minimal nonsense to begin with, so it is hard to post a link to something that will work and will meet your needs.
  9. You must put a HTML <img src="url_that_produces_image_goes_here" alt=""> tag on your page for each image. The url_that_produces_image_goes_here is the URL to your .php script that outputs the content-type header followed by the image data.
  10. See the following sticky post, particularly the last reply about the byte order mark characters - http://www.phpfreaks.com/forums/index.php?topic=37442.0
  11. FYI - variable variables are three times slower than using an array and you have a lot of variable variable references in your code. The $_FILES['image'] or $_FILES['userfile'] (in the original code) structure is already an array of arrays. All you need to do is use a simple foreach loop (see Example #3 at this link - http://us3.php.net/manual/en/features.file-upload.post-method.php ) to iterate over the uploaded file information.
  12. You don't even need the first query/loop. It is not doing anything that your second query doesn't alreay do. Your goal, when retrieving information from a database, should be to execute ONE query that gets the data you want, in the order that you want it. You then simply iterate over that data and output the results the way you want them to be. You should be ordering the data by the target_type in the (one) query and then put if($row['target_type'] == 'Weight Loss'){ tests inside the (one) loop that iterates over the data.
  13. session_register was depreciated over 9 years ago (in favor of $_SESSION variables), finally throws a depreciated error messages in php5.3, and has been removed as of php 5.4. DON'T use session_register in your code and any code that current uses it must be updated to use $_SESSION variables.
  14. You have a spelling error in your query.
  15. Your form's select field is named 'name' - name="name". You would need to reference that same name in your php code using $_POST['name']
  16. The variable you put into the mysql_result() statement is not the variable you assigned the result resource from the mysql_query() statement to.
  17. It's likely that your php.ini settings changed or reverted to the default for either output_buffering or error_reporting/display_errors and your file that dynamically produces the image is outputting something in addition to the content-type header and the image data. Comment out the content-type header statement and browse directly to the URL of your file that produces the image to see if there are any php errors being output or if you can then see any characters before or after the image data, in comparison to the image that you are having the code save to a file.
  18. Your script that is producing the image is probably outputting some characters either before or after the image data. When you have the script save the image as a file, those extra characters are not saved with the file. Make sure that there are no extra characters before the first opening <?php tag or after the last closing ?> tag and that you are not echoing anything, producing any php errors, or have any closing/opening php tags that have some white-space between them.
  19. < and > have meaning in HTML (they indicate the start and end of HTML tags.) You need to use < and > You can also use htmlspecialchars or htmlentities to get php to convert them for you.
  20. PFMaBiSmAd

    MAIL()

    Edit: Basically says the same as what thorpe posted above ^^^ In order to use your web host's mail server with a remote php script, you will need to use SMTP Authentication. The php mail() function does not support SMTP Authentication (it is basically an unauthenticated email client without any support for supplying the mail box's username/password.) To use SMTP Authentication, you need to exchange SMTP commends directly with the mail server. Fortunately, there are several php mailer classes that do this for you. Two of the most popular are - php mailer http://phpmailer.worxware.com/index.php?pg=phpmailer and swift mailer - http://swiftmailer.org/
  21. A) You are not even calling your function. B) As xyph posted, you have a variable scope problem. The $string variable you set inside your function does not exist outside the function. You need to return the result that your function produces. C) What phily245 posted are two different syntaxes that produce the exact same result and don't have anything to do with your problem. D) You should have php's error reporting set to E_ALL and display_errors set to ON so that php will help you by displaying all the errors it detects. You will save a TON of time. You would be getting an undefined error message at the $string variable in your main code, alerting you to the fact that it has not been set (see items A and B in this list.)
  22. You need a connection to the database server before you can use mysql_real_escape_string. You should also have php's error_reporting set to E_ALL and display_errors set to ON so that php would be reporting and displaying all the errors it detects. You would be getting connection errors at the mysql_real_escape_string statement because it attempts to create a connection when a connection does not already exist.
  23. Using the database engine (compiled code) to find just the matching rows, will be at least 10x faster than using php (a parsed, tokenized, interpreted language) to loop over, convert (you don't actually need to convert yyyy-mm-dd dates to timestamps to compare them), and test all the values to find which ones to operate on. Plus, because the query you posted is only retrieving the expiry_date, you likely have other query(ies) inside of your php loop that is(are) retrieving related data. By using a single query (joined with related tables as needed) that gets only the data you want, you can likely make what you are doing 20x faster (important if your site becomes popular or if your web host starts threating to suspend your account for using too many resources), You will also end up with less total code that you must write, test, and maintain (important if you are getting paid to do this or when you need to make changes to the code in the future.) Database engines are designed to efficiently find data, php is not. Php is designed to be an easy to use, general purpose, programming language. Use each for what they were designed to do and you will end up with the simplest, quickest, and most efficient end result. For example, assuming that your rows in the model table contain all the needed information (otherwise this would be a JOIN query statement), the following query will get just the rows that you want - SELECT * FROM model WHERE expiry_date BETWEEN CURDATE() AND CURDATE() + INTERVAL 3 DAY The only php code would be to loop over the result from that query and use each row. There would be no php code to form or convert dates or test each date.
  24. When you tried this, exactly where did you get stuck? At getting a for(){} loop to produce those values or outputting the values in HTML that would produce a table? Edit: Or styling the table so that it has 100% width?
  25. eMonk, did you look at your own code? After you have written some code, before you ever execute it, you need to 'play computer' and proof-read/step through your code, line by line, to make sure the logic you have written does what you want. You are accessing $row['expiry_date'] before you have even set $row. How would that ever work? However, you should never retrieve all the rows from a database table, then loop through them to find a matching condition. You would use a WHERE clause in your query to retrieve just the row(s) you are interested in. You also would never put an include statement for something like the pear mail class inside of a loop as that would redefine the class every pass through the loop. You would include the mail class one time near the start of your program.
×
×
  • 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.