-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
The error message is self explanatory. Your products table does not have a column named category. Check your spelling of the actual column name.
-
Here's an additional suggestion for any form submission - After you have successfully processed a form submission, you actually need to redirect to the same page as the form's action="" attribute to change the browser's history for that page from a form submission to a GET request so that the browser won't attempt to resubmit the data should you browse back to that page. If you have single page or separate pages for the form and the form processing code, anytime you browse back to the page that matches the action="" attribute of the form, the browser will attempt to perform the last operation it has recored in the browser's history for that page.
-
opendir expects the path to the directory that is to be opened. Directories are accessed using the operating system. You are trying to use a URL and in fact you are specifying a URL to an image - iamge.png. Even if you could use a URL with opendir, giving it the URL to an image is not what opendir is used for.
-
Organising data from mysql - lost my head!
PFMaBiSmAd replied to gibbonuk's topic in PHP Coding Help
Databases are not spreadsheets. Don't spread out same meaning data in columns in one table or use separate tables to hold same meaning data. If you were to post an example showing the meaning and purpose of your data, someone can probably help with how your table(s) should be organized. -
The simplest solution is to put the form and the form processing code on one page. Any existing post data is available to put back into the fields and you can validate and display any errors next to the field they apply to.
-
login to a speciic page based on unsername
PFMaBiSmAd replied to site-spin's topic in PHP Coding Help
I would recommend against using hard-coded php logic to map each user with his data or what he can do or access on a page. Doing so would require that you go into your code and edit it every time you add a user. That makes work for you (or the person you are creating this site for - he's a php programmer himself and could successfully find and alter the code?) instead of getting the computer to do the work for you. The solution you should be working toward is what szezulak suggested. For your current log in code, if you don't already have it, I would suggest adding an id (userid), which is an auto-increment column in your users table. You would fetch the id and assign it to a session variable when someone logs in (in addition to the username.) You would also store this id with each photo filename in a database table that associates the client with his photos. When the client logs in, his id would be used to query for a list of his photo filenames that would then be dynamically displayed on one common page (you should probably also have a 'jobid' so that any one client can have multiple sets of photos.) The reason for having one common dynamically populated page (you should look into pagination to allow x photos to be displayed at a time) that would display the photos for the currently logged in client, would be so that there is only one page that needs to be coded and the look and feel of the site is controlled in one place and again, you are trying to get the computer to do the work for you instead of you creating page after page after page that only differs in the data that it displays. -
You cannot just randomly change parts of your code and expect it to work. You have added an $offset variable in all those queries but you are not setting a variable by that name. I suggest that you read the pagination tutorial that I linked to.
-
Sorry to jump in, but you would calculate the LIMIT based on the page and the number of results you want per page. Something like - $offset = ($currentpage - 1) * $rowsperpage; Where $rowsperpage is your $display variable and $currentpage looks like it is (should be) your $start variable. See this link for a pagination tutorial - http://www.phpfreaks.com/tutorial/basic-pagination You also have too much repetitive code that is probably making it harder to see what your actual code is doing. Your first block of if(){} elseif{} statements that is building the query to find now many total rows can be reduced to just - <?php if (isset($_GET['np'])) { $num_pages = $_GET['np']; } else { $where = "1"; // default switch ($viewstate) { case "open": $where = "status='Open'"; break; case "pending": $where = "status LIKE 'Pending%'"; break; case "closed": $where = "status='Closed'"; break; } $query = "SELECT ticket_number, first_name, surname, email, product, retailer, DATE_FORMAT(dop, '%d %M %Y') AS dop, message, address, DATE_FORMAT(created, '%d %M %Y %r') AS created, status FROM support_dev WHERE $where ORDER BY ticket_number ASC"; $query_result = mysql_query ($query); $num_records = mysql_num_rows ($query_result); if ($num_records > $display) { $num_pages = ceil ($num_records/$display); } else { $num_pages = 1; } } Since the above code is already building the base query, you don't need to repeat all the logic again to just add the LIMIT clause on the end. Just use the following where you are building the query to get the actual rows - <?php $query .= " LIMIT $offset, $display"; $result = mysql_query ($query); $num = mysql_num_rows ($result);
-
I feel like chef Gordon Ramsay. Did you look at where the errors where occurring at in your code and TRY to find what was causing them? Both are very simple things. The first one is in this line - $price = mysql_real_escape_string($_POST['price']); Where is $_POST['price'] coming from? Could you look at your form and try to determine why the price field is undefined. The second one is in line 2 of your INSERT query statement. Could you look at your query statement and try to determine what is wrong with it near the first of the six data values.
-
Select results from 2 tables in different databases on same server?
PFMaBiSmAd replied to localtechguy's topic in MySQL Help
You would use a UNION query to get same structured results from more than one table. -
Are you sure they are spaces? If they are tabs or new-lines, the mysql TRIM() function would need to be told which characters to specifically trim -
-
You can trim spaces from the field by executing the following query using your favorite database management tool (phpmyadmin or similar) - UPDATE sheet2 SET cpt = TRIM(cpt)
-
How did you get the data into the table? If you did some kind of csv import, you likely have some non-printing characters, such as a space or a new-line, as part of the data and you won't be able to do an exact match with it without stripping the excess characters.
-
The {} are needed around associative array variables inside of strings so that you can keep the quotes around the associative key name without breaking the string syntax. You can also use them around any php variable inside of a string for those cases where you need to tell php where variables start and end. See the Complex (curly) syntax section at this link - http://cn.php.net/manual/en/language.types.string.php
-
Leading zero's on numbers in php cause them to be treated as octal. 08, '08', 09, and '09' are not valid octal numbers.
-
Are you sure you reloaded your page to get the changed javascript code to be loaded and changed your php code to use $_POST variables?
-
LOL, if you use the following code in the end of your vote() function, the data will be available in score.php as $_POST['id'] and $_POST['rating'] - var dataString = "id="+id+"&rating="+result; $.ajax({ type: "POST", url: "score.php", data: dataString, success: function(msg){ alert("Counter updated" ); } });
-
@mikelsanderss, is your password field in the table the md5 of the actual password? You are going to need to troubleshoot what your code, query, and data are doing in order to find out why it is not matching the information stored in the table. Start by forming your sql query statement in a php variable and echoing that variable so that you can see exactly what the query is. Then execute that query directly against your database using your favorite database management tool (phpmyadmin or similar) to see if it matches any rows and then check directly in your database table if there is a row that exactly matches the values in the query.
-
Redirect to a new page after form submitted?
PFMaBiSmAd replied to popcop's topic in PHP Coding Help
After you have successfully processed a form submission, you actually need to redirect to the same page as the form's action="" attribute to change the browser's history for that page from a form submission to a GET request so that the browser won't attempt to resubmit the data should you browse back to that page. -
@popcop, you need to start your own thread for this in the correct forum section.
-
String data values must be enclosed by single-quotes within the query. You should also store the date of birth information in a single mysql DATE data type field - YYYY-MM-DD
-
You have a spelling error in your defined constant - STORE_XML_FILE vs STORE_XML_FILES If you had error_reporting set to E_ALL you would have gotten a notice error where you tried to use the non-existent STORE_XML_FILES
-
If you post your whole form (so that someone doesn't need to create a page to test the code you did post), someone would likely try and find why it is not working.
-
Sending output to browser before headers... why DID it work?
PFMaBiSmAd replied to jhsachs's topic in PHP Coding Help
I didn't see that your reply #8 had been posted (sometimes the SMF software doesn't show all posts when you click the "show unread posts since your last visit" link.) Are you actually using a web server on your localhost development system? It would appear that you are using some IDE or debugger and one or both of them could be causing the unexplained symptoms (in fact most debuggers work by manipulating the actual code that is executing and using output buffering to capture the debugging output.)