Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. Or are you checking if the upload worked without any errors before you attempt to use the uploaded file information in the rest of your code?
  2. Pagination involves two queries, the first one to get the total number of matching rows (so that you can correctly calculate and limit the number of pages) and the second query to get the actual block of rows that corresponds to the page number that was requested by clicking on the link. See this tutorial - http://www.phpfreaks.com/tutorial/basic-pagination
  3. If you don't want to unlink the old image file when it has a different name then the new image, you would remove the logic or comment out the unlink statement in the code - if (!empty($old_picture) && ($old_picture != $new_picture)) { @unlink(MM_UPLOADPATH . $old_picture); }
  4. That's because you are NOT outputting the data for each performance where the logic requires you to do so. There was a comment at the correct place -
  5. So, you are uploading a new profile image. Well, your code is unlinking the old image if it's name is different than the new image name (if they are the same name the new image overwrote the old image) so the old image no longer exists and any rows in the conversation table that contain the old image name won't match any image file.
  6. Your logic that is testing - if (!$result) { is only testing if the query produced an error (i.e. the query could not be executed at all due to a connection problem, a sql syntax error...) That does not mean that the query matched zero rows. To test how many rows the query matched, use mysql_num_rows Edit: here's the typical logic you should use for every SELECT/SHOW query (queries that return a result set, even if there are zero rows in the result set) - <?php $query = .... your query statement .... if(!$result = mysql_query($query)){ // query failed due to an error, handle that here... } else { // query executed w/o any errors, test if there are any rows in the result set if(!mysql_num_rows($result)){ // no rows in the result set, handle that case here... } else { // one or more matching rows in the result set, handle that case here... } }
  7. The reason we don't understand what you are stating is because some of the terminology you are using is a bit off, probably because your interpretation of what is happening between the browser and the web server is a bit off. When you request any page from the web server, the web server sends the requested page back to the browser, then the web server goes on to service other http requests. The web server is not sitting there waiting for you to submit a form and in fact other than a line in the server's access log file, there is no evidence that a page containing a form has ever been requested. There is no 'background' processing going on, just http requests to the web server and the response that the server sends back to the browser. When the processing on the server reaches the end of any page that was requested, all the resources used by that page are destroyed. Each http request is completely separate from every other http request. For any form (it does not matter what the action= attribute is) when the browser submits the form, it makes a http request for the URL supplied by the action= attribute and it submits the form data to that URL. For the case of an empty action="" attribute, that just means that the browser requests the same URL that the form is on. For the case of an absolute or a relative URL in the action attribute, the browser either uses that absolute URL directly or produces an absolute URL from the current page and the relative URL information. In your example where you have an empty action="" attribute, when you submit the form, the page in the browser actually completely changes to whatever your code outputs to the browser in response to that http request, but it sounds like the code on your page outputs the form again along with a status message. In your example where you have a different page as your action= attribute, it sounds like you don't have the complete code needed to process the form submission as part of that target page. Any php code that exists on your form page only exists on the form page.
  8. I don't understand what you are talking about either (we are not standing right next to you and don't know what you saw in front of you) and I have a significant amount of experience decoding what people state in their posts. Are you seeing the actual php source code of the changemail_script.php file?
  9. long is a reserved mysql keyword and is causing a sql error in your query. You should always have error checking logic in your code to test if queries work or fail with an error. To use long as a column name, you must enclose it in back-ticks `` every time you use it in a query or more simply, rename your column to something else.
  10. The confusion occurs because almost all of the edits that we see alter the meaning of the initial post, such as what the question or code actually is. This results in the people that are trying to answer that initial question look like fools because their answer doesn't match the now altered question. It also wastes the time of those making replies by causing them to be chasing a wild goose of a question. Short answer: If the initial post is lacking in information or is poorly stated or wrong (make sure before hitting the submit button), add a reply that clarifies the information so that an accurate history is maintained of the posts/replies in the thread. The time limit on editing posts is not an arbitrary decision, it is based on seeing thousands and thousands of threads where people try to answer the question that they see posted. Altering that question after you post it kills the chance of getting people to continue helping you.
  11. There will be, they will just be all the same actual single page of code. The URLs of the 3 different search pages will be your_page.php?category=1, your_page.php?category=2, and your_page.php?category=3. The code I suggested WILL only display the correct information for whatever category (Car, Van, Motorbike) that was chosen. Give it a try. Based on the code you did post, the few modified lines that I posted are the only things you would need to change. This method I have suggested is used all over the Internet The forum you are on now only has one page - index.php. Everything you do on this site that is forum related simply uses GET parameters on the end of the URL to tell the code in index.php what it should do for any page request.
  12. A leading slash / on a file system path refers to the root of the current hard disk. File system paths are not URLs and a leading slash / does not refer to the domain root like it does for a URL. See this post for how you can get the path to your document root folder - http://www.phpfreaks.com/forums/index.php?topic=348498.msg1644442#msg1644442
  13. I'm guessing you are sending continuous data without any line break of the correct type - message Message to be sent. Each line should be separated with a LF (\n). Lines should not be larger than 70 characters. What operating system are you creating/editing your code on? If your editor is using a \r only as a new line character, you are likely exceeding the length that the mail server will process and it is breaking the line/running up against a bug in it's code. Insure that your message body is using \n for new lines.
  14. If your Default_Code value for vans is an empty string in the database table, yes it would be better to use - Default_Code = '' On the subject of having only one page that you must maintain, in just the little bit that I looked at your code, you have a lot of inconsistencies between the pages in your markup and a lot of invalid markup. If you did something like the following at the start of the page, you can use one page for all three categories - <?php // either use an array in a configuration include file (shown inline for this example) or store/get this information in/from a database table $cat_info[1] = array('title'=>'Car Roof Racks','default_code'=>"= 'LE'"); // car "LE" $cat_info[2] = array('title'=>'Van Roof Racks','default_code'=>"= ''"); // van (if it is an empty string in your table) $cat_info[3] = array('title'=>'Motorbike Racks','default_code'=>"= 'MB'"); // "MB" // condition the 'category' input/set default $cat = isset($_GET['category']) ? (int)$_GET['category'] : 1; // default to 1 (Car) // validate the requested category if(isset($cat_info[$cat])){ // category found, set up common variables used on the page $title = $cat_info[$cat]['title']; // page title $default_code = $cat_info[$cat]['default_code']; // query search term $search_header = strtoupper($title); // strong header used in form } else { // category value is not supported, handle that condition here... die('Invalid information requested!'); } In the code on the page, you would use the values that are set in the above code - <title><?php echo $title; ?></title> $sqlSelect = "SELECT DISTINCT Car_Make FROM products WHERE Car_Make <> 'all' and Car_Make <> 'link' and Default_Code $default_code and Car_Make <> 'n/a'"; $sqlSelectModel = "SELECT DISTINCT Car_Model FROM products WHERE Car_Make = '".$strMake."' and Default_Code $default_code"; <td height="29" bgcolor="#FFFF99"><div align="center" class="arial11"><strong><?php echo $search_header; ?></strong></div></td> $query = "SELECT DISTINCT Car_Make FROM products WHERE Car_Make <> 'all' and Car_Make <> 'link' and Default_Code $default_code and Car_Make <> 'n/a'"; The menu where you allow the visitor to pick the category would need to be modified to use the ?category=x, but with the category information stored in an array, you can let php produce that menu for you - <?php // build menu - $cat_menu = "<ul>"; foreach($cat_info as $key=>$arr){ $cat_menu .= "<li><a href='?category=$key'>{$arr['title']}</a></li>"; } $cat_menu .= "</ul>"; echo $cat_menu; // output menu where you need it ?> You would also use the ?category=x method in your the form action="..." attribute on that page so that you only have one form processing page.
  15. oops, I didn't see that the query was using a different value than what the form processing code is producing. That's what you get when you have unnecessary lines of code in your program. There's no guarantee that when the form is submitted that the SELECT query is putting a value into the $row variable. You will need to debug at what point you have expected data and at what point you don't. When you examine the conversation data table directly, does it have the expected values in the correct columns? Since your insert query doesn't list the columns, we have no way of even knowing if the query is formed correctly. Also, echo out that query to make sure that it has the expected values in it. When you say you are changing the image, what exact step/code are you referring to?
  16. Your middle code that inserts into the conversation table has a form with username, topic, and quote fields. It does not have a picture field, so of course there is no picture data in the conversation table. 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 report and display all the errors that it detects. You should not set error_reporting in your code (except for strictly debugging purposes) and you should certainly not set it to hide any of the types of errors. You will save a ton of time. You would have gotten an undefined error at the reference to $_POST['picture'] that would have alerted you to the problem. Also, if you are making this code for a real site, you need to validate ALL external data that your code receives. In this case your validation logic would have told you that there was no $_POST['picture'] value and your logic would have prevented the insert query from executing without all expected data.
  17. The following is the logic you are trying to use - <?php $last_eventtitle = NULL; // remember the last EventTitle while ($Row = mysqli_fetch_assoc($TheatreResult)){ $eventtitle = $Row['EventTitle']; if($last_eventtitle != $eventtitle){ // a new or the first EventTitle was found if($last_eventtitle != NULL){ // not the first EventTitle, close out the previous section // code to close out the previous section goes here... (if your layout needs to do this) } $last_eventtitle = $eventtitle; // save the new EventTitle // output the heading/start a new section // code to output the heading goes here... } // code to output each piece of data under the heading goes here... } // code to close out the last section goes here... (if your layout needs to do this) ?> The only places you should be echoing anything are where the comments in the above indicate.
  18. I'm going to guess that the problem is in the code that edits/updates the database. You are perhaps altering the existing image name (adding a space or a cr/lf would be enough) so that the code that outputs the image/nopic no longer finds the corresponding actual image file. What is the rest of your code needed to reproduce this problem, including any code that produces your 'edit' form?
  19. Now that we know what you are doing and what the general problem is you are trying to solve, how big are these image files, because the time taken to send them from the web server to the browser could be many times more than the extra overhead due to storying them in a database, and caching the image on the server as a file won't help if the problem is due to the transmission time. Also, if the overhead of retrieving the image from the database and dynamically outputting it using php code is where the problem is at, and you want to cache the image as an actual file in the file system to solve the problem, doesn't that suggest that images should be stored as files in the first place and should not be stored in a database?
  20. Do you have a specific example? How you cache something depends on what it is and how 'expensive' it is to produce/reproduce. Reading a remote file would involve saving the whole actual file in the cache so that you don't need to reread the remote file. Caching a web page that uses an 'expensive' database query would involve saving the resultant HTML page so that you can just output the resultant HTML without executing the query again. Caching a parsed/tokenized version of a template would save the time needed to parse/tokenize it, but would still require reeding it into the template class so that the resultant code can be executed at runtime.
  21. You are missing records from the result set because you have a mysql_fetch_array statement, between your query and that start of your while(){} loop, that is fetching and discarding the first row from every result set.
  22. Define: unauthorized access to the document root? If someone has sufficient access to the files on the server, NOTHING you do will protect the contents of any of your files (no matter where you put them) or database data.
  23. You remember the date value and output a new heading only when the date changes. See the logic in this post - http://www.phpfreaks.com/forums/index.php?topic=342485.msg1615743#msg1615743
  24. ORDER BY last_name_column, first_name_column
×
×
  • 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.