Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,340
  • Joined

  • Days Won

    173

Everything posted by mac_gyver

  1. and to get the data from dynamically created form fields, the field name needs to be an array - http://us1.php.net/html#faq.html.arrays so that the data can be processed as an array in the php code.
  2. is the value 1,000 or is it 1000. these are different to a programming language because the , is a stop character that would result in the value 1 being used.
  3. php's error_reporting would probably help track down the problem.
  4. what sort of database library functions is your db::getInstance() class using (mysql_, mysqli_, PDO)? the reason i ask is that your code is also using mysql_real_escape_string() and without a mysql_connect() statement, it won't return any result. it would also be throwing a php error if you had php errors being reported and logged/displayed. the reason this works on your development system is that some of the WAMP all in one development packages set up default mysql connection details matching your root database user and would allow a mysql_real_escape_string() function to work, whereas a live server wouldn't be doing such nonsense. you should be escaping string data (or using prepared queries) using a method present in your db::getInstance() class, not using mysql_ functions. edit: i see that in your recent threads on this forum that you are using the PDO database library functions. you would use the PDO quote() method. however, be advised that this adds the single-quote characters around the data, which means that you must remove the single-quotes you have in your existing sql query statement. in cases where you are putting external data into an sql query statement, you should use prepared queries, which will avoid all the problems like this associated with trying to escape/quote string data.
  5. @josephbupe, programming help forums are not for getting people to write code for you. they are for getting help with code you are writing. if it's beyond your programming skills to do something that you want, you will need to hire someone to do it for you. if you do have your own programming that you have written and need help with, start your own thread for it. topic locked.
  6. you can use fseek() to start reading from a file at a specific location, but you will need to know the location. if all the blocks of data are the same length, you can just create an index (stored in its own file or a database table) of which numbered block corresponds to the date/time of the data, then just do a little math (block number * length of each block) to find the location to fseek() to. if the blocks are variable length, you can create an index (stored in its own file or a database table) of the actual offset that corresponds to the data/time of the data. just get the filesize() of the log file before you write new data to the file. the filesize() value would be the fseek() location for the new block of data. store that in the index with the date/time of the data.
  7. extracting an array to individual variables would just create a mess of individual variables, that if you are then planning on using variable-variables to reference, will take three times longer than referencing the data in an array. are you sure that the time taken is in the processing of the data or is it in the query(ies)? have you profiled the code to pin down where the majority of the time is taken? for all we know you are running queries inside of loops on data that is lacking needed indexes or that you are repeatedly opening/closing a database connection. the example data tells us little about the problem. your actual complete code is what is important in terms of helping with a performance problem. the only thing that is apparent from the hinted at code - $placeDataHere['DV_' . $date]['SM_' . $key] = 'KS_' . $value; is that by adding text prefixes to these three variables that ALL the processing is slowed down by the extra code need to reference the data using the synthesized keys. in fact, why are you even storing data it in the $placeDataHere array? just use the $date, $key, and $value directly in the code. since you must retrieve the data from two different database servers, the typical things that would help with the speed would be - 1) only retrieve the data you need (for all we know you are retrieving far more data than gets used.) 2) do as much processing in the sql queries as possible (for all we know the actual processing of values involves data from only one of the servers and could be handled in the query and returned relative to just a key value to be used by the php code to combine it with the data from the second server.) 3) since the processing is likely on a per-user basis, the data in the arrays should be organized per-user (i'm guessing the $key is user related) so that related data is grouped (see item #4.) 4) eliminate actual loops by using array_map()/array_walk() with call-back functions to do the processing (requires that the data be organized in a way the aids processing.) short-answer: you must first find where the time is being taken up at in the code, then address what that portion of the code is doing.
  8. <?php= does not exist. <?= would become <?php echo (with a space between the echo and any following value) this isn't an Apache problem. it's a php configuration problem and people using php's lazy-way short-cuts in code they publish for others to use that is not portable between php versions/configurations.
  9. the characters being added are BOM (Byte Order Mark) characters, times 3. your posted php code/html don't appear to have them in it, though the process of editing/copy/pasting for the post could have removed the characters. i have never seen a case where a browser added BOM characters to form data values, so it's most likely that your php code/html has them in it, probably due to copy/pasting code from somewhere it was published at with BOM characters as part of it. the code you didn't post was - what code do you have that does anything with $_POST['token'] through to the point where $token gets set? you can narrow down the problem further by using var_dump($_POST) at the start of your processing code; to see if the characters are coming in with the post data or if they are being added by the processing code.
  10. safety is not in which functions you use, it is how you use them. you can write code that uses either the mysqli or pdo functions and it can still allow sql injection. the reason that PDO gets recommend over mysqli is that the mysqli library is not consistent and is a PITA to use with dynamically prepared queries.
  11. your examples imply these 'parameters' are actually data values, that the function/method code will operate on as a set of same meaning data. in this case, you would pass them into the function as an array of data, so that the function can operate on any arbitrary amount of data without needing to ever alter the code definition or dynamically produce or dynamically call code, as the amount of data changes. your second example also implies that you are hard-coding these values into a verbose amount of repetitive code, rather than use array functions to have simple general-purpose code operate on the set of data by looping over the data. as an example of why you would NOT use individual parameters that represent same meaning data, just look at the php mysqli_stmt_bind_param() function and what it takes to use it with an arbitrary number of data values.
  12. unless you have a database table named, literally, $user, with the $ as part of the table name, your query is failing due to an error. 1) you need to ALWAYS test if your queries have actually ran without any errors before you try to use any of the data from your query. mysqli_query() will return a false value, that can be tested, when the query has failed due to an error. you can use msyqli_error($conp) to find out what the actual error with the sql query statement is. 2) if $user and $ticker are php variables, php variables are NOT parsed and replaced with their value when used inside of overall single-quoted strings. you would need to use double-quotes around the $sql = "..."; string to get php variables inside the string to be replaced with their value. 3) you should also use single-quotes around the '$ticker' variable, since double-quotes inside of an sql query statement can be configured to mean they indicate a column name, whereas single-quotes inside of a msyql query statement will always mean a literal siting value. 4) you should have php's error_reporting set to E_ALL and display_errors set to ON to get php to help you. the mysqli_fetch_array() statement, along with the $row references, are throwing php errors to alert you to the fact that the query failed due to an error.
  13. all external data - $_GET, $_POST, $_COOKIE, $_REQUEST (don't use $_REQUEST anyways), $_FILES, and some $_SERVER/$_ENV can be anything that anyone want's to submit to your script. if you are putting any external data values into a sql query statement, they must be treated appropriately to prevent sql injection. this means to escape string data and properly validate/cast numerical data OR use prepared queries. also, internal data that could ever contain any sql special characters must likewise be treated appropriately to prevent sql errors. i notice that you have variables for a table name and column name in your query. hopefully, you are not getting these from external, user submitted data, because using a database escape function on table/column names won't prevent sql injection and you cannot supply table/column names through place holders using prepared queries. lastly, the mysql_ functions are OBSOLETE and should not be used when writing new code and if you have old code using them, now is the time to start converting your code to use either the PDO or msyqli_ database functions so that your code will continue to work when the mysql_ functions get removed from the php language.
  14. it's not different sessions. per my reply, you are echoing it in the wrong place in your code -
  15. the reason you cannot echo the $_SESSION variable when your form is being displayed, and get the correct value, is because the code generating the value in the $_SESSION variable and producing the image is a separate http request from the browser that occurs long (in terms of computer processing) after the php code for your form has ended. why do you want to echo it, on lines 17-19 of your code, which is outside of the form processing code? you can echo it inside your form processing code, which runs on the http request after the form and the image have been displayed.
  16. the correct length is 32, which the second one has. the first one has some extra non-printing characters in it somewhere. what does the 'view source' in the browser of the var_dump() output show? what's the code that's responsible for setting the $token variable and if it is coming from a form, what is the code producing the form field it's being passed in?
  17. in your last post, you need to show us what the print_r() output actually is, because it may hold a clue as to the problem. also, when you check only one or two boxes, not all three, is the result correct?
  18. use var_dump() on both values to help see if they contain any white-space/non-printing characters.
  19. we can only help when you post specific information, i.e.your code, a sample of the input data your code receives, the result you got from your code for that data, and the result you expected.
  20. 268,435,456 bytes (250+ MBytes) is a SIGNIFICANT amount of memory for any script to use and if when you change the memory limit, the amount of allowed memory listed in the error also went up to 512,xxx,xxx and then 1,024,xxx,xxx bytes, this indicates a script that will consuming all available memory, no matter how much you make available to it. the script could either have a logic error that's consuming all memory (loading an array with the same data over and over in a loop for example) or of a script that needs to process a large amount of data, but isn't managing memory usage very well or at all. in any case, you, or better yet, the program's authors, will need to debug what the code and data are doing to find what's causing the large memory usage. edit: i downloaded the script, and the api/pipe.php page specifically sets the memory limit to 256M in the code.
  21. php code is normally only parsed when in a .php file, not a .js file.
  22. exactly what does the 'view source' of the page show for the whole line where the php variable is at?
  23. the php version you listed still has register_globals available. any chance that at some point in your testing you set a $_SESSION['user_rights] or a $_COOKIE['user_rights] variable with some values that could be now overwriting your $_POST data?
  24. when the only thing that varies when an input value changes is an output value (i.e. you are mapping one value to another), you would not use hard-coded conditional logic to do this, as that would mean that you must find where in your code the values are hard-coded at and then alter the program logic every time you you add, change, or remove a value. you would use a data-driven design, where the mapping is stored in a data structure, such as a database table or an array, depending on how much data there is, and the only thing the general-purpose code does is take the input value and make use of the mapping data structure to obtain the result. the code doesn't change just because the amount of data or the data values change. it's really beyond the scope of a post in a forum to feed you everything you would need to know to create a proper database driven content management system. you need to do some research and experimentation on your own and post specific questions you may have. here is an example of a data-driven design that took multiple sets of same program logic that only varied in the data values being operated on and changed it to use a mapping data structure, with one general purpose set of code that doesn't change just because the amount of data or the actual data values change - http://forums.phpfreaks.com/topic/291619-multiple-if-statement-not-working/?do=findComment&comment=1493538
  25. based on what you are showing, you are planning on creating actual files - index.php, jobs.php, region.php, ..., but put (include) the same code in each file, that than needs to map the base filename to a search value. this is not the correct way to do this, as it results in a bunch of 'wrapper' files that must be maintained and managed every time you add, change, or remove a category/search type. the correct way of creating a content management system, would be to store the categories/search types in a database table, then you would have a single page that uses the contents of that database table to produce navigation links and to take the category/search type id/name from a submitted link to find the content to display on the page.
×
×
  • 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.