Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,448
  • Joined

  • Days Won

    174

Everything posted by mac_gyver

  1. i would recommend against unconditionally looping over all submitted form data (a hacker/bot can submit hundreds/thousands of pieces of data.) you should know what fields your form will submit and if you are dynamically adding fields, their names should be of a known scheme (array names) so that you know what to expect when you condition, filter, validate, and process the submitted data.
  2. there are two possibilities - 1) the information from the error reporting logic is correct and there is a path/file that is somehow hidden. 2) the information from the error reporting logic is bogus (hard-coded copy/pasted path/file information) and the error is occurring somewhere else. you apparently have a set of files present in your off-line copy, that you recently uploaded to the server at the point this problem started. did any errors occur while you were FTPing the files (i.e. you actually did upload and replace all the files on the server)? i would recommend that you zip all the files (less your database connection credentials) and a attach them to a post in this thread.
  3. this error is occurring on the server too, but is it not being reported/displayed. your code is not running at all on both your development system and your live server because this is a fatal parse error in the php source code.
  4. you would do my paragraph #2, less the need to sort the name. the following should (untested) work (is based on the code you posted showing name, eventname, and points as the actual data being retrieved) - // pre-process the data $events = array(); // a list of all the unique event names in the retrieved data $data = array(); // the data that was retrieved while($row = mysqli_fetch_object($DriverPoints)) { $data[$row->name][$row->eventname] = $row->points; if(!in_array($row->eventname,$events)){ $events[] = $row->eventname; // remember unique event names in the order they were retrieved in } } // use the data // output your table heading here.... // output the table data foreach($data as $name=>$arr){ $total = 0; echo "<tr><td>$name</td>"; foreach($events as $event){ $score = '--'; // default is 'did not participate', display '--' or anything else you want if(isset($arr[$event])){ // there is data for the event $score = $arr[$event]; $total += $score; } echo "<td>$score</td>"; } echo "<td>$total</td></tr>\n"; }
  5. you can use your database library's error function to find out why the database selection isn't working. which database library is the code using? mysql, mysqli, pdo, ...? it's either doesn't exist by the exact name being used in the code or there's a permission problem or a database connection problem.
  6. ummm. yes you can use the copy() function, but you should use the move_uploaded_file() function.
  7. i'm not sure how you are going to use this data, but assuming an array that only has the $col_keep columns left in it will work, try this - $col_keep = array_flip(array('A', 'B', 'D', 'K')); // make these values into the array keys foreach($sheetData as $k=>$v) { // $v is the array you want to filter $keep = array_intersect_key($v,$col_keep); // intersect using the keys print_r($keep); }
  8. your latest posted code is still missing the $ in front of the MyFile variable name and is therefor not reading the file at all. you would be getting several php error messages. you need to set php's error_reporting to E_ALL and display_errors to ON to get php to help you. as to the extra characters on the end of the $confirmation_number value, where or how are the POST values being generated and submitted?
  9. in looking at your code more, the code that is exploding the data is having a problem with the lines that have the y","13.95" on the end because that price will be in $line_data[2], along with the closing double-quote. you need to use either fgetcsv() or str_getcsv() (php5.3 or greater) to parse your csv data. the following is how you can do this using str_getcsv - $file = $_FILES["phile"]["tmp_name"]; $lines = file($file,FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); // read the lines into an array array_shift($lines); // remove header line $lines = array_map('str_getcsv',$lines); // convert each csv line to an array // loop over the lines and process them foreach($lines as $line){ echo '<pre>'; print_r($line); // examine data to see what it is // your processing code... }
  10. if your stored procedure returns the data in the order that you want it, sorted by the name,eventid and there are rows for every name for every eventid, it would be simple to produce this output as you loop through the rows of the result set. just detect when the name changes, finish any previous table-row output, and start the next table-row output. however, if the data isn't in the order that you want it or there are not rows for each name/eventid, you will need to pre-process the data, storing it into an array as cyberRobot suggested, with the name being one index and the eventid being the next. you could then sort the array by the names and find the min/max eventid's. you would then loop over the names and loop over the range of eventid's, accessing any data stored using the array indexes or using a default value when there's isn't any data for any name/eventid.
  11. ^^^ if that's meant to be about my post, the line i posted was just an example of how to use isset() to avoid the errors. the current errors the op is getting are on these lines - 40 - $splititupsomemore = explode(',', $line_data[1]); 49 - $pd_price = str_replace("\r", "", addslashes($splititupsomemore[1])); 51 - $pd_spc = addslashes(substr($splititupsomemore[2], 1)); 57 - $pd_spc_price = addslashes(substr($splititupsomemore[3], 1));
  12. post #4 in this thread has nothing to do with your problem. it's probably just a spammer testing if the account he created works.
  13. the offset errors you are seeing were probably always present, but php's error_reporting/display_errors settings were hiding them. you are attempting to reference array elements that don't exist because the data didn't have some of the optional elements. the proper coding method would be to test if an optional piece of data exists and then take an appropriate action (use a specific default value when it doesn't exist.) you can use isset() to test if a php variable/array element exists. the Ternary Operator (short form if an if/else statement) makes writing the code straightforward - $pd_spc_price = isset($splititupsomemore[3]) ? addslashes(substr($splititupsomemore[3], 1)) : 0; // use the actual value or a default (zero in this case) some other points - 1) the mysql_ database library is depreciated and all code should be switched over to use the msyqli or pdo database libraries. 2) you should escape data being put into a query using the database library's string escape function or even better use prepared queries. addslashes that you are using doesn't escape all the possible characters in all the possible character sets and can allow sql injection. 3) if you are regularly inserting a large amount of data, a multi-value insert query, inserting 2-5K rows at a time, will run many times faster than inserting rows one at a time.
  14. assuming you are json_encoding the data, replace the alert(data) with - unavailableDates = data;
  15. slightly different slant on the problem - the error reporting logic in your code should log that information when on a live server, rather than outputting it to the visitor. an easy way of controlling what is logged or displayed is to use trigger_error() as that will let you use php's display_errors/log_errors settings to control where your error reporting logic sends the output.
  16. neither do we because there's no specific information in this thread. just a general answer would be, alter the database query(ies) so that it(they) only use the product field. what third party script is this? (a link to the author's download page would help.)
  17. it probably has something to do with the value being assigned to $current. i'll bet if you try, you can probably find what is causing the problem fix it yourself. edit: hay, someone stuck a green badge under my avatar!
  18. do you have php's error_reporting set to E_ALL and display_errors set to ON so that php would help you with things like session_start() error? also, have you even determined that your code is taking the execution path you think it is and is setting the $_SESSION variable to a specific expected value?
  19. // get the numeric part function _num($val){ preg_match("/(\d)+/", $val,$d); return $d[0]; } $var1 = array("PK100","PK101","PK102","PK110","PK120"); // some data $result = array(); // where to put the results $index = 0; // sub array in the results for each consec series of data $current = _num($var1[0]); // get starting numeric part foreach($var1 as $value){ $num = _num($value); // get numeric part if($current++ == $num){ // consecutive $result[$index][] = $value; } else { // not consec $current = $num; // the new starting numeric part $index++; // the next sub array in the result $result[$index][] = $value; } } echo '<pre>'; print_r($result);
  20. there's nothing specific in the posted code/data/css that would do this (and didn't when i tried with just the posted code.) i suspect the problem in the use of var content = $('#contentCMS').html(); getting the actual html of the element, with any css styling you are applying on the page. try using the .text() method.
  21. you mentioned typing in information. you would only want to type ORIGINAL information when you first enter it into your database. if you already have information in a database, you would use some sort of menu to let the user pick it. you apparently are trying to do this using a select/option menu, but your html is missing the <select name='...'></select> tags and the form input fields you do have both have the same name='...' attribute so only the last field will be submitted. the LIMIT clause in your query(ies) also raises questions. it is skipping over the first two rows and NO one would look at or scroll over 6000+ entries on a page. you would present some sort of search/category/type-a-head-lookup to present a smaller set of choices. have you defined exactly what you want for a user interface, before trying to write any of the code for it? using column names (and variables) like COL 2 also isn't going to get you much sympathy or help on programming forums. you need to use names that convey the meaning of the data, so that you or anyone else that might need to look at your code/queries can determine the intent.
  22. then you will probably want to design your program LOGIC to do that, one step at a time - 1) display your country select/option menu. since you are trying to tell your page what output to get/produce as a result of the request for the page, you should use method='get' in your form. this will cause your country id selection to be passed in the URL so that it persists between page requests. 2) when the $_GET country id selection is present on any page request, you would run the code needed to use that selection to query for and display the information that matches that country.
  23. rather than just dumping your code on a forum, what have you done to troubleshoot what your code is doing? is your form processing code running at all? is the while(){} loop running? what are the exact values being tested by your logic statement- if ($_POST[$q] == $answer) { (hint: user var_dump() to see the value and length of a php variable)
  24. string data values must be enclosed by single-quotes inside the query statement so that they are treated as literal string data values, otherwise they are treated as identifiers (database, table, or column names - which is what is occurring in your case) or treated as mysql keywords, functions, or operators. programming requires that you know the meaning of everything in the code in front of you. to successfully write a sql query statement, you must know the syntax for the type of query you are writing, what the keywords, functions, and operators mean and where they go in the query, where the identifiers (database, table, or column names) go, where the data values go, and how to treat each different type of data.
  25. you would take the currently selected id and find a row with where the id is greater than that id, limit 1
×
×
  • 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.