Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. What value exactly is in the $includes variable? Something tells me it is a URL - http://yourdomain.com/somepath/
  2. I would recommend writing a database class to serve as a wrapper/interface. You would then search and replace the existing query/fetch/num_rows/affected_rows/error calls with the replacement class methods. I would then test using mysql(i) statements in your class to insure you didn't break anything. Then all you would need to do is concentrate on making the class methods produce the equivalent results using Oracle command/queries.
  3. If you want the specific row in a group that corresponds to a max (or other specific) value - http://dev.mysql.com/doc/refman/5.5/en/example-maximum-column-group-row.html
  4. Getting the date value through the form means that anyone can change it to anything (the readonly attribute WON'T actually stop anyone), so you must validate it and escape it before putting it into your query statement to prevent sql injection. The value you put into your query should a value that is derived only on the server. See Pika's reply above on how you can do this directly in your query.
  5. ^^^ I don't believe you What is your current code?
  6. P.S. Your login check/permission code is not secure and won't stop anyone from accessing your 'protected' pages. You need an exit; statement after the header() redirect to prevent the rest of the code on your page from running while the browser is requesting the new page in the the redirect.
  7. You are unconditionally outputting the success message without testing if the query did anything. Since you are assigning the result from the query to $result, add the following code to test what the query actually did - if(!$result){ // query failed with an error of some kind, do some error reporting here - die('INSERT query failed. ' . mysql_error()); } else { // query executed, test if it actually inserted the row if(!mysql_affected_rows()){ // row was not inserted. This is rare and would generally require the use of the IGNORE keyword in the query to cause a query error to become a warning only. die('INSERT query ran, but did not insert the row.'); } else { // query ran and did insert the row - echo "<font color='green'>User account added successfully."; echo "<br/><a href='ausers.php'>Return to Users List</a>"; } }
  8. The three blocks of PHP code you have in amongst the javascript logic ALL runs on the server when the page is first requested. So, the two session variables will always have the last two values that are being set. You would need to submit a value with the form that indicates what operation to perform.
  9. You would add a unique key to your existing table definition - UNIQUE KEY `somename` (`products_id`,`sessions_id`)
  10. To get specific help to any programming question, you must post the specific information/code you have in front of you that causes the problem. No one here can possibly help you with the content of your .htaccess file without seeing it. There can literally be a dozen different things that could be causing any one symptom or error and there's no way to narrow the list down without seeing the relevant information.
  11. You can just create a composite key using the two existing fields.
  12. I would find and fix the problem that is causing a query to take that long. It's rare that a query will take longer than a second to run.
  13. STOP adding your post onto the end of existing threads. Your previous post was split into it's own thread - http://forums.phpfreaks.com/topic/270197-cant-insert-title-into-database-split-from-existing-thread/ No matter how similar your problem is to an existing problem, it's a different problem.
  14. A) It's the browser that is doing the urlencoding and there's nothing you can do to stop it. B) The actual $_GET data available on that page has been urldecoded and is correct.
  15. See your previous thread. Two different people posted example code showing how you can do this.
  16. What value were you expecting the string 'S123', which starts with a non-numerical character, to be converted to for comparison with an integer field, 0.2? If you are putting a value like that into a query statement in a place where an integer value is expected, it seems like you are not validating your data properly before using it in a query. You shouldn't even have single-quotes around that value inside the query (mysql convents a single-quoted string to a floating point value when used in a numerical comparison.)
  17. SQL stands for - Structured Query Language. One of the reasons it has been suggested that you use a database for this is because writing a database SQL query statement to do what you want, search (filter) for specific information becomes trivial - $query = "SELECT a, list, of, columns FROM your_table WHERE FirstName = '$search'"; Let a database engine do the work for you, rather than you re-inventing the wheel writing your own code to search in your text data. Also, the compiled code of a database engine will be at least 10x faster at finding the data than your parsed, tokenized, interpreted, relatively slow php code will be at finding the data.
  18. No one what? Without the current code (i.e. the it) and the symptoms or errors you got (not working doesn't tell us any useful information) when you ran that code, no one here can help.
  19. This isn't a server issue, unless you had a problem setting the error_reporting/display_errors settings on your server. It's a problem in your code. You should be learning php and developing/debugging php code on a local development system. You will save a TON of time. Only complete and tested code should be put onto a live server.
  20. There's three things that are slowing your code down. 1) You have a wall of repetitious hard-coded logic (all the if(){} statements.) Using a data structure to simplify the logic will speed up the code because there will be less of it to run each pass through the program. 2) You are updating multiple values in any one row by using multiple queries. Using one query to update all the values at once will reduce the execution time of your script to about 1/3 of what it is now. 3) You are running queries inside of a loop. To fix item #1, you need to use a data driven design. What this means is you have a data structure somewhere (array, database query) that defines the data/limits/key-values ... that your code will use. For example, if you have an array that associates the 'src' values (5101, 5102,... = gahanna, 5201, 5202, ... = jtown, ...), all that massive wall of if(){} blocks of code simply becomes - <?php $lookup = array(); // a 'lookup' array of the keys/values $lookup[5101] = 'gahanna'; // other values here... $lookup[5201] = 'jtown'; // other values here... $lookup[5301] = 'canal'; // other values here.... ... if(isset($lookup[$row['src']])){ // The $row['src'] value exists in the $lookup array // $lookup[$row['scr']] is the correct svc_loc value to use in your query } To fix item #2, just use one UPDATE query - UPDATE your_table SET column1 = 'value1', column2 = 'value2', column3='value3' WHERE your_where_condition. Combining #1 and #2, your EXISTING query logic would look like - <?php $lookup = array(); // a 'lookup' array of the keys/values $lookup[5101] = 'gahanna'; // other values here... $lookup[5201] = 'jtown'; // other values here... $lookup[5301] = 'canal'; // other values here.... ... $result = mysql_query("SELECT * FROM TABLE WHERE calldate between '$_POST[start]' and '$_POST[end]' "); while($row = mysql_fetch_array($result)){ // unconditionally set In_out to 'in' (it is set to 'out' later if 'src' is in a specific set of values) $query = "UPDATE TABLE SET In_out = 'in' WHERE uniqueid = '$row[uniqueid]'"; mysql_query($query) or die("Update Failed: $query" . mysql_error()); if(isset($lookup[$row['src']])){ // The $row['src'] value exists in the $lookup array $query = "UPDATE TABLE SET In_out = 'out', ext_name = '{$row['src']}', svc_loc = '{$lookup[$row['src']]}' WHERE uniqueid = '$row[uniqueid]'"; mysql_query($query) or die("Update Failed: $query" . mysql_error()); } $get_ext = substr("$row[dstchannel]", 4, 4); if (strpos($get_ext,'51') !== false) { $svc_loc = "gahanna"; $query = "UPDATE TABLE SET svc_loc = '$svc_loc', ext_name = '$get_ext' WHERE dstchannel = '$row[dstchannel]'"; mysql_query($query) or die("Update Failed: $query" . mysql_error()); } if (strpos($get_ext,'52') !== false) { $svc_loc = "jtown"; $query = "UPDATE TABLE SET svc_loc = '$svc_loc', ext_name = '$get_ext' WHERE dstchannel = '$row[dstchannel]'"; mysql_query($query) or die("Update Failed: $query" . mysql_error()); } if (strpos($get_ext,'53') !== false) { $svc_loc = "canal"; $query = "UPDATE TABLE SET svc_loc = '$svc_loc', ext_name = '$get_ext' WHERE dstchannel = '$row[dstchannel]'"; mysql_query($query) or die("Update Failed: $query" . mysql_error()); } } I don't have time right now (edit: but Psycho did, see his post above), but since the code has been reduced, it is easier to see what it actually is doing (see the forest for the trees), making it easier to eliminate the queries inside of the loop.
  21. How about posting that error message. It tells the file name and line number the error occurred at and what type of error was detected.
  22. The following is your code for the current/active page - echo $i . ' '; I's not a link. It's text. Someone already showed you how to put a span around it to style it with a css class.
  23. Where in your code do you see a link being output for the current/active page? There are links for the previous page (if any), the pages other than the current/active page, and the next page (if any.)
  24. If you mean the currently selected page, it's just the page number, not a link. You would output the page number inside of a <span class='selected'>$i</span>
×
×
  • 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.