Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,449
  • Joined

  • Days Won

    174

Everything posted by mac_gyver

  1. you shouldn't have that many different queries to look at. i do have some suggestions - 1) search for the mysql_query(....) statements to find where all the queries are at. 2) remove the actual sql query string from inside the mysql_query(....) statement and form the query string in a php variable, $query for example, then put the php variable into the mysql_query($query) statement. this will separate the query statement from the code running the query. this will accomplish a couple things - 1) allow you to echo/log the actual sql query statements to help with the process of rebuilding your database table structure (it also helps with normal troubleshooting), 2) allow you to more easily eliminate the mysql_ functions, which are depreciated and need to be changed to either mysqli or PDO functions. 3) while you are doing item #2, convert any * in the query to the actual list of column names, gotten from the references in the php code that is fetching the data from the query. looking at how the php code is using the data will also help identify the data types for the columns. 4) you could at this point write your own query function that accepts the $query variable, echoes or logs the query statement, runs the query with error checking, and echoes or logs the error, then returns the result from the query to the calling code. you would do a search/replace to change all the mysql_query() statement names into a call to your own query function. 5) examining the echoed/logged queries and query errors will help you iteratively create the tables/columns. 6) after you have finished recreating your database tables and every query runs error free, convert your code to use either the msyqli or PDO database functions.
  2. the question has been asked many times before and there has never been a script/link posted that does this, primarily due to the variability in how queries can be formed (you could for example use a defined-constant/variable for any part of the table or column names) and how the data can be fetched from a query and with people using things like SELECT * (it would take knowing what php variable the result is fetched into, then find either the array index names or object property names...) is your actual database lost/corrupted or a just your defining .sql file, because you can always get the table definitions from the actual database.
  3. your data, a string with length 1, that doesn't display anything, is likely a null character \0 is that an expected value, either as a default or an intentional value?
  4. a) what scanner program? b) in there a chance you opened/closed the file in your programming editor, which could have added the BOM characters to the file? c) you could always read the file using php, remove the leading BOM characters, then save the file.
  5. it is likely that your file has been saved with the BOM (byte order mark) characters. use your programming editor to save it without the BOM. if the file itself doesn't contain any utf-8 encoded characters, just save it as an ansi/ascii encoded file. also, that indicates your database column definitions are all probably a character type. your userid should be an integer, your date should be a date data type, and your time should be a time data type (or your date/time should be combined into one datetime data type.)
  6. what does using the following show for the value you are trying to test - var_dump($row_rsPRODFULL['LEDdimmable']);
  7. the leading \ (windows) or / (non-windows or windows - php converts / to \ on windows) refers to the root of the current disk. no one here suggested or showed using require_once '\class.phpmailer.php'; as to the error message, when i try require_once '\class.phpmailer.php';, i get messages referring to '\class.phpmailer.php'; i'm guessing your version of php has a bug (they have had several concerning the include/require _once.. functions.) see if it works correctly using the suggested require_once 'class.phpmailer.php';
  8. just to summarize - 1) using require_once '../class.phpmailer.php'; is specifying a relative path and does not use the include_path setting. the include_path is mentioned in the error because it's a generic error message. a relative or an absolute path requires (no pun intended) that the file be at the resulting relative or absolute path. 2) the suggestion to use require_once 'class.phpmailer.php'; is based your statement that the class.phpmailer.php file is present in the folder mentioned in the include_path setting. this should work, except that you stated the ../ relative part of the path is still being shown in the error message. 3) if the error still mentions the ../ relative part of the path for the file, your problem is that the changes you are making to your main file are not being used. your file either got saved with a .php.txt extension and didn't actually replace the original or you have multiple files at different locations and are editing the wrong one or you are not saving the file into the correct location in your document root folder and an older version is being used.
  9. how long does your script take to run, using microtime(true) at the start and end and calculating the difference?
  10. if would help if you posted your current error message and the current code. the error may have changed slightly and would provide a clue as to the current/continuing problem. edit: as to your code change not being reflected in the error above in the thread, that's a sign that the code running isn't the code you are changing. you either have multiple lines trying to include/require this class file and are not changing all occurrences or you have multiple main files and are changing the wrong one or not saving it to the right folder.
  11. there's something about your actual data or something about how you are displaying/using the data that is causing it to not appear when being viewed or used. if this is being output in a browser, what does the 'view source' of the output look like?
  12. you have two different $content variables. the one from the $_POST variable, which is empty, is overwriting the one holding the table name, so there is an empty table name in the query.
  13. i'm guessing you are missing a sesison_start() statement that would allow any session variable to exist. do you have php's error_reporting/display_errors turned full on so that php will help you? using the organization mentioned in your last thread and in this one, some untested logic that should work - <?php session_start(); include "../edb.php"; $query = "SELECT * FROM `afddocs_adviser_comm` WHERE AdviserCode ={$_SESSION['uid']} order by DateUploaded DESC"; $result=mysql_query($query); $data = array(); while($row = mysql_fetch_assoc($result)){ $data[] = $row; } mysql_close($conn); // end of the business logic // the following is anything to do with presentation if($_SESSION['uid'] == 1){ // width='610' Detail 1 - Detail 5 $width = 610; $details = array(1=>'Detail 1','Detail 2','Detail 3','Detail 4','Detail 5'); } else { // width='270' Detail (1) only $width = 270; $details = array(1=>'Detail'); } // the html document (template) follows - ?> <body> <table width="680" border="0" align="center" cellpadding="4" cellspacing="0"> <tr><td> </td></tr> <tr><td class="text-heading"><p>Commission Statements</p></td></tr> <tr><td> <table width="<?php echo $width; ?>" border="0" align="center" cellpadding="4" cellspacing="0"> <tr class="text-sectionheading"> <td width="100">Date </td> <td width="85">RCTI</td> <?php foreach($details as $legend){ echo "<td width='85'>$legend</td>"; } echo "</tr>"; foreach($data as $test){ $id = $test['id']; echo"<tr>"; echo"<td class='text-questions'>{$test['DateUploaded']}</td>"; echo"<td><a class='{$test['RCTIcssclass']}' href ='{$test['RCTIURL']}'>{$test['RCTIImageType']}</a></td>"; foreach($details as $key=>$not_used){ $class = $test["Detail{$key}cssclass"]; $url = $test["Detail{$key}URL"]; $imgtype = $test["Detail{$key}ImageType"]; echo"<td><a class='{$class}' href ='{$url}'>{$imgtype}</a></td>"; } echo "</tr>"; } ?> </table> </td></tr> </table> </body>
  14. you need to code for the differences, not the common things. you also need to put the 'business logic' up front, then put the 'presentation logic' at the end to eliminate duplication. is the session uid being a one the only occurrence where you output the 2-5 details?
  15. these unexplained problems are usually caused by something other than the code being focused on. to let someone duplicate the problem your PAGE is having, post all the code, less any database credentials/actual url... that would be needed to reproduce the problem. i'm guessing things like a conditionally defined variable, multiple page requests, some initial condition assumption, is the cause.
  16. here's a simple fix. when manipulating existing data, you should be referencing it by it's id, an autoincrement index in your defining (product) table. there's no need to pass anything else around in the url and in fact you seem to be passing several of the stored fields in the url. that's just redundant information that is not needed. as to your actual inventory data storage, you should not keep just a quantity. it's too easy to have a double posted value mess it up, then you have no record of what went into making up the current quantity. you need to treat your inventory as a credit/debit account, just like your bank checking account, with one row for every 'transaction'. you then sum up the + and - amounts to come up with the current inventory for any or all item id's in the inventory table.
  17. the reason your code didn't tell you about the error is you need to setup pdo to throw exceptions. after you create the instance of the pdo class/make the connection, you need to add - $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  18. you need to first define the conditions you want to implement. do you want to include the items that have been added into carts as reducing the available quantity, even though someone may never actually complete the process to purchase the items in a cart, i.e. an abondandoned cart? this could lead to temporarily telling someone they cannot add an item/quantity to their cart, even though there could be enough actual quantity available. or do you only include the items that have actually been ordered as reducing the available quantity? this would allow the total amount of any item added into carts to exceed the actual available quantity. when someone actually completes a purchase you might end up telling them that the item is not available, would be back-ordered or that they need to remove or reduce the quantity of the item to complete the order process. or do you code for both of these. use method one if you cannot obtain any more stock of an item (it was a one-time/one-off purchase) and use method two if you can obtain more stock of an item and will allow partial shipments/back-orders. now to the actual determination of the quantity available. first, you need an inventory table to keep track of things like inventory added, adjustments in inventory for things like store losses, fire, damage... this will have, as a minimum, columns for - id, item_id, quantity (signed int) next, you need an order_details table (you also need an orders table, but that is not directly related to determining available quantity.) this table will hold the lists of items that have actually been ordered, one row for each item in each order. this will have, as a minimum, columns for - id, order_id, item_id, quantity, status. the status column indicates things like ordered, shipped, returned, canceled, lost, ... lastly, to use method one, where the items in carts are counted against the available quantity, the carts need to be stored in a database table so that you can use a query to easily, quickly, and directly determine the available quantity. to determine the available quantity for method two above - select item_id, sum(quantity) as qty from ( select item_id, quantity from inventory WHERE item_id IN(123,456) union all select item_id, -quantity from view_order_details_allocated WHERE item_id IN(123,456) ) x group by item_id the IN(123,456) term is a list of the item id's for the cart you are displaying/processing. in this example, the query will return the available quantity for item id's 123 and 456. the view_order_details_allocated is a view for the order_details table where only the status values that make that item allocated/unavailable are matched, i.e. ordered, shipped, lost, ... to determine the available quantity for method one above, you would just extend this to factor in the carts - select item_id, sum(quantity) as qty from ( select item_id, quantity from inventory WHERE item_id IN(123,456) union all select item_id, -quantity from view_order_details_allocated WHERE item_id IN(123,456) union all select item_id, -quantity from carts WHERE item_id IN(123,456) ) x group by item_id
  19. since this is not ms sql, moving to the php help forum (your problem is the usage of the php functions, not the actual query, yet). you should also be getting a warning/error message for the mysql_query() statement, it is the cause of the error you did post. when php functions are supplied with invalid parameters, they return null values now. there's three problems with the mysql_query() statement in that code - 1) the order of the parameters for mysql_query() are - ($query , $link_identifier) 2) you are putting an empty string into a variable named $db_name and putting that into the mysql_query() statement. that makes no sense. the database name belongs in a select_db statement or in the actual sql query statement. it is not a parameter in any type of current query() statement. 3) the msyql (no i on the end) functions are depreciated. you should be using mysqli or pdo functions so that you don't have to rewrite your code at some point in the future.
  20. except for these people in the new members group with avatars and none or a few posts that probably signed up via a facebook or twitter account - http://forums.phpfreaks.com/index.php?app=core&module=search&do=viewNewContent&search_app=members&sid=f6b11ffff83974a2c7ecab7c2fb95fc3&search_app_filters[forums][searchInKey]=&period=today&userMode=&followedItemsOnly=0 if that link doesn't work, use the upper-right menu 'View New Content', then the left-hand menu 'By Content Type' - 'Members'
  21. assuming that the column order is not important, i would implode the lines from each describe table query into an array, one element per line, then use php's array_diff() on the two arrays. if the resulting array is empty, the two tables contained identical definitions.
  22. that's the url for your live server. go back and read what i wrote.
  23. if php is outputting the expected html, this will work. it would take seeing your actual php code (less any database credentials) in order to help you with what your php code is doing or not doing.
  24. what url are you using in your browser to access your localhost development system, it should be something like - http://localhost/your_file.php
×
×
  • 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.