Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,449
  • Joined

  • Days Won

    174

Everything posted by mac_gyver

  1. the first error means you have included conec.php more than one time, thereby redefining the Connect() function. you would need to determine where in your code you are including it and make sure you only include it once. you either have multiple include statements or an include statement inside of a loop. the next two errors are because you have used a column name (spelling or capitalization) that doesn't exit. you would need to identify which query in your code is on line 161 (we cannot because the posted code doesn't match the line numbers) and determine which column name doesn't match your table definition. the last error message is self explanatory, did you read it at all and try determine what about your query is causing it?
  2. you have been told that the posted query and posted code cannot produce the errors you are reporting. there's nothing technically wrong with that query. you were also told it's possible that the code inside your loop can be causing one of the errors you are reporting. since you doubt that's the case, there's nothing more that we can tell you because this process of remotely debugging what is going on in your code requires that you have the ability to question and to investigate what your code is doing in order to find where and what the problem is.
  3. there is a way that your posted mysql_fetch_xxxxx() statement can produce the posted error, but that would require that the code inside your loop is running a query that's overwriting the $result variable.
  4. no one here is going to write code for you. as i stated above, the error you reported cannot be coming from the posted code.
  5. the query and php code you have posted CANNOT have produced a query is empty error. the query is empty error does NOT mean that the query didn't match any rows. means that the actual sql query statement supplied as a parameter to the mysql_query() statement was empty. either that's not the actual code or the query with a problem is somewhere else in your code.
  6. to check if code in any file is running, you can add code to it to append a line with the date/time to a log file - file_put_contents('log.txt',date('Y-m-d H:i:s')."\r\n",FILE_APPEND);
  7. no one has answered this because your code is a thrown together mess that no one can figure out what it is doing, so no one can tell you what's wrong with it. you also did not provide the actual html input data that corresponds to the desired output, that would be needed to experiment with the code (no one here is going to reverse engineer what the code is doing in order to come up with sample input data.) you have variables and functions that are not used; variables used as array indexes that are both not initialized, nor incremented; code repeated four times, that only differs in the input variables it uses; code that's retrieving all the html data (apparently from your own site), then inside the loop that's processing that data, gets more data from your own site; and i suspect a lot of the code isn't even being used to produce the output xml data, it's just left over from some example you copy/pasted. you need to start by writing (rather than copy/pasting) just the code you need that will get the job done. you also need to answer a question that has been asked before. are you getting this html from your own site (in which case you should be just using the original data that is producing the html) or are you just posting a dummy url that makes us think you are getting the html from your own site?
  8. anyone can submit anything they want to your web page. your dropdown menu means nothing as far as security is concerned. you MUST enforce security on the server. ALL external data cannot be trusteed.
  9. here's another important concept - DRY (Don't Repeat Yourself). you should never repeat code, especially if you want people in help forums to look at your code. when you post a wall of code, it cuts down on the number of people that will even look at it. the parts of your code that are common, should be factored out and not repeated. the only conditional code should be what changes between those two cases. another point of not having a wall of code is it makes it easier to see what the actual code is and what might be wrong with it. the reason for your incorrect result is you have one = in the if ($doctype = 'all'). this assigns the value 'all' to $doctype and then tests if that is true or false. since the string 'all' is a true value, your code always runs that branch of code. two == is an equal comparison. some more tips - 1. you should use alias names in your query statements (more DRY. repeating the table name 5-10 times just leads to typo's...) 2 you should build your sql query statements in a php variable. this allows you to echo/log it for debugging purposed and separates the query statement from the php code that runs it. 3 if $order_results comes from user supplied values, you must validate that what you put into the query only contains expected values to avoid sql injection. 4) your Year, Month, and Day columns should be ONE field of type DATE (YYYY-MM-DD.) you can then use that directly to order by and if you need it in any other format, simply use the mysql DATE_FORMAT() function in your query. 5) you apparently have two fields in common between your Full_Documents and Readings tables? that's a bad design. the relationship between related data tables should use one value, the primary id of the main table. based on your column names, do you even have a primary id assigned to the Full_Documents table? you also have some mis-located { } in your if/while logic. equivalent code, without any repetition - $dbh = new PDO("mysql:host=$dbhost; dbname=$dbname", $dbuser, $dbpass); $type_term = ''; $parms = array("%$search%"); if ($doctype != 'all') { $type_term = 'AND d.SectionTypeID = ?'; $parms[] = $doctype; } $query = "SELECT d.FullDocumentID, d.DocType, CONCAT(d.ReadingNo, '-', d.SequenceNo) AS full_doc_number, CONCAT(r.Month, '/', r.Day, '/', r.Year) AS date, CONCAT(r.Year, '-', r.Month, '-', r.Day) AS DateOrder FROM Full_Documents d, Readings r WHERE d.ReadingNo = r.ReadingNo AND d.SequenceNo = r.SequenceNo AND d.SectionText LIKE ? $type_term ORDER BY $order_results "; $stmt = $dbh->prepare($query); $stmt->execute($parms); $num_records = $stmt->rowCount(); if($num_records > 0){ // note: this block of code can be replaced with one fetch_all() statement $links = array(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){ $links[] = $row; } } also, moving to the php code forum section as this is more php code, rather than just the html of a select menu.
  10. the answer is probably yes. you changed the structure of your data and it no longer matches what the query in the event is doing.
  11. if your goal is to allow a Select All Documents/default choice to exist, you would assign a unique value/keyword to that choice and the server side code would test for that value/keyword and take an appropriate action (i.e. build the query without the $doctype term in the WHERE clause to match all document types.) if your goal is to allow the multiple attribute to work (i.e. the user can select any combination of the choices), you must make the select name attribute an array - name="doctype[]" and process the data on the server as an array of values (using the IN() mysql comparison function in the WHERE clause.)
  12. the code from the tutorial site works, there's no specific bug in it to be found. it just has shortcomings that make it unsuitable for use on a real web site. you need to determine what the code is doing when it runs to find at what point it is not doing what you expect in order to find what the problem is. for anyone here to help, you need to state what does happen when you submit the login form (even a blank-page is a clue) in order to narrow down the dozens of possibilities to just a few things to check further.
  13. the point of tutorials are for you to learn from them. rather than you just repeatedly dumping all your code and errors/symptoms on a programming help forum and expect someone else to find and tell you what to do (we already know how to read and troubleshoot code and don't need the practice), what debugging have you done to find out what the code is doing? btw - the 'secure' login script you found and are trying to follow is just a demonstration of the secure login concepts the author came up with and it is not a well written or usable script. it's a minimal 'application' and lacks error checking logic that would tell you if and why things like queries are failing.
  14. since you didn't post the mysqli_ version of the code, how could we possibly help with what might be wrong with that version of the code? also, in the following code, why are you testing the sql query statement string variable? - if (!$strQuery) { die("query failed:" . mysql_error()); } all that code is doing is testing if the sql string is true/false.
  15. from the documentation for the function mentioned in the error message -
  16. a) is your cron job running? b) you would need to debug why your cron job isn't updating/creating the cached files. c) what is your page/site doing that is taking a long time, as threads like this generally need to start by fixing whatever problem is causing the long page generation time, rather than to apply a band-aid over the top of the problem.
  17. your query didn't match any rows and $result is a false value instead of an object from the mysql_fetch_object() statement. the WHERE clause in the query is false, either because there's no row where id = '$this->id' or $this->id may be empty. where did you get this code? it doesn't have any error checking logic (the errors in some of your previous threads), nor is it testing if the query matched any rows before trying to use the data from the query (the error in this thread)?
  18. you didn't answer the specific question i asked. anyway, after making an assumption about that specific case, see this code - <?php $file = fopen("new.csv","r"); $makeArray = array(); while(! feof($file)) { $lineVal = fgetcsv($file, 0, '@'); // Adds in 'Make' to initial makeArray array if ( isset($lineVal[0]) && empty( $lineVal[1] ) && empty( $lineVal[2] ) ) { $make = $lineVal[0]; $makeArray[$make] = array(); continue; } // Gets Model lists - first/only line with a $lineVal starts a set of data and lists the model(s) if ($lineVal[1] !== '') { $names = explode(",", $lineVal[1]); foreach($names as $name) { $makeArray[$make][$name] = array(); } } $OEMs = explode(',', $lineVal[2]); // there can be multiple parts listed on any line foreach($names as $name){ foreach($OEMs as $oem){ $makeArray[$make][$name][] = $oem; } } } // Echo results echo '<pre>'; var_dump($makeArray) . '<br />'; echo '</pre>'; fclose($file);
  19. the reason i asked for better/more complete data is because it's not possible to solve programming problems unless all the rules have been defined. what result do want when there are multiple OEM parts, such as the last section in your screenshot with two OEM parts each.
  20. based on your screenshot, all you would do is detect when the the nth field, the list of models, is not empty, and use that detection to end a previous set of data and start the new set. if you post some believable csv data, corresponding to the screenshot, someone might help with code that would do this.
  21. your html is invalid, there's no closing </select> tag, so everything being output is not rendered and can be seen in the 'view source' of the page in your browser. you need to always make sure your web pages are valid html at http://validator.w3.org
  22. where and how is the search term $q being input? have you echoed your $query to make sure it contains what you expect?
  23. sorry to jump in here, but the code you have on your site has a much more serious problem than just fixing the code above that's selecting information. the code somewhere in it has allowed a bot script/hacker to insert/update the category information in your com_catalogue database table. that injected sql is present in your database table. is this script some sort of open source shopping cart or where/how did you obtain it? the reason i ask is based on the security holes, inefficient/amateurish code, and outdated usage of mysql_ functions, it should be scrapped and replaced or completely rewritten. edit: i guess it's also possible that $category is being set through some other means, like register_globals or via some $_GET logic above the posted code, and is not coming from the first query in the posted code. in any case, this code is not secure and fixing one small part isn't going to make it a secure script.
  24. what is it that you are trying to solve, as there may be other ways to accomplish the same thing?
  25. nope. hashes are one way. any sort of cryptography encoding/decoding produces longer data than the source, as does base64 encoding/decoding. the only way to shorten long data is to find repeated sections that are long enough and occur frequently enough to justify processing them, store one copy of the repleted section along with a short token value, then replace each repeat region with the short token. reverse to get back the original. edit: see the lossless sections at this link - http://en.wikipedia.org/wiki/Data_compression
×
×
  • 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.