Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,537
  • Joined

  • Days Won

    192

Everything posted by mac_gyver

  1. you would start by storing the dates using a mysql DATE data type, so that you can do date comparisons (to select the range of dates you are interested in) and so that you can order the data by the date. you would then run a query that selects the data you want in the order that you want it. you would probably want a secondary sort order on the description so that the links are in alphabetical order within any date. you would fetch the data into a multi-dimensional array, using the date as the main array key/index. this will give you a sub-array of data for each date. because the quote data is not directly related to the links data, you would query for it separately and fetch it into its own array using the date as the array key/index. you would then just loop over the main array to access each date, then loop over the sub-array for each date and output the data the way you want. you would use the date value from the main loop to access any quote(s) for that date in the quote data array.
  2. is the openssl extension installed and enabled? you will need it for php to be able to establish a https connection.
  3. it's probably something in the 'dbconfig.inc.php' file. or if the posted code is being included/required into another file, it's coming from something in the main file.
  4. // set a default value if not already set - if(!isset($_SESSION['posY'])){ $_SESSION["posY"] = 50; } // and if you really, really, really are creating more variables holding values that you already have variables for (what's wrong with using $_SESSION["posY"] ?) - $posY = $_SESSION["posY"];
  5. are you sure about the spelling and capitalization of the path in all cases, in all the code and when looking for the file? could you also have a /home/lineligh/public_html/art3/artwork/ folder or a folder with a space in a part of the path? how are you submitting the data to the form processing code and viewing the result from your debugging statements? you could have a case where the data is being submitted twice, the second time without any successfully uploaded file, and the file is being deleted. the only requirement in your logic to run the move_uploaded_file() statement is that $_FILES['picture']['name'] is set. this however doesn't guarantee that there is a successfully uploaded file. lastly, does your server have the stupid Suhosin hardened kluge present? it has a habit of making perfectly good code, not work?
  6. it's likely that your actual complete code is deleting the file after you have moved it to the folder. i'm betting if you put a die; statement after the echo '<br>$result: '.$result; line, that the file will be present in the folder. edit: btw - how do you know the file isn't in the folder? what method are you using to get a listing of the files, since the fault may be in the method being used?
  7. if you review your previous thread on the forum ( http://forums.phpfreaks.com/topic/279439-simple-shopping-cart/ ), where you were using array indexes with sequential numerical endings, the same as what you are doing now, someone suggested a simplified approach that reduced the amount of code to almost nothing. you need to define a data structure that supports what you are doing, not make it harder. i'm betting if you use the same approach that was suggested in that previous thread, and use the name as the array index and the corresponding value as the array value, and just delete (unset()) the element(s) from the array, it will solve your problem.
  8. and do you have control over this application such that you would be able to change or define what form and format the output data is presented as? does this data source have the ability to send the data to a web server (to a URL) or does it require human intervention to get it to produce and display the data? if you don't have any control over the data source, you will need to write code to process the data in whatever form and format it is available as. getting people to list all the possible ways to do something isn't useful, since all the suggestions may not even be compatible with the data source. care to share some actual information about what this application/data source is and what form (file, text output on the display on a computer, ...) this data is available as, so that the suggestions being given will be targeted to the actual problem?
  9. first of all, you are asking about a value in a column, not a row. the answer is to add some programming logic to the code that's INSERTing the data. they call this stuff software for a reason. if it doesn't do what you want, you can change it to suit your needs. you should actually have a jobtype table that defines the different jobtype names and assigns a jobtype_id to each one. it's the jobtype_id that should be stored in the jobtype column. you should not be regularly dumping this data into a combined database table. you should do this once for the existing data, then use the single combined database table from that point forward.
  10. no. you cannot just change the name. the parameters that the two different sets of functions took are different. you must read the php.net documentation, for whatever function you are trying to use, so that you will gain an understanding of what parameters it requires and what they mean. there are also basic examples to be found in the php.net documentation along with user contributed notes.
  11. start with the first error message. i'm betting it concerns an undefined variable $id on about line 12 in your code. this is the line of code - $sql = mysql_query("SELECT * FROM products WHERE id='$id' LIMIT 1"); where in your code, prior to that line, have you defined a variable named $id and assigned it a value? the answer is you haven't. unfortunately, php at one time (14 years ago) would have defined the $id variable, based on the existence of the $_GET['id'] variable. this however resulted in a huge security hole and was turned off by default 14 years ago and was finally removed from php a few years ago. for there to be a variable named $id, you must create it and assign a value to it from the $_GET['id'] variable or you must use the $_GET['id'] variable in your code. however, putting external data directly into an sql query statement allows sql injection and anyone can run any sql they want on your server. the best way of preventing sql injection is to use prepared queries, with place-holders in the sql statement were data goes, then bind the actual data or variable holding the data with the place-holder. also, the mysql_ functions are obsolete and have been removed in the latest version of php. you should be learning to use either the PDO (the best choice, especially if using prepared queries) or mysqli_ functions. lastly, for the rest of the undefined variable errors. your page is dependent on there being an id value to put into the sql query statement, the sql query running without any errors, and upon the sql query finding a matching row in the database table. if all three of these conditions are not met, there will be no data to display. in this case, you should output a appropriate message on the page to let the user know what's wrong and not try to reference non-existent data.
  12. javascript does not provide any protection for the server-side code. any value that anyone or a bot script wants, can be submitted to the server-side code, without using any of your client-side code (other than to learn the field names to use.) the server-side code must have protection in it.
  13. you have to use all sqlsrv_ functions. the mssql_ functions are obsolete and haven't been available on windows since php 5.3.
  14. the header('location: ...') is only telling the browser to make a http request for a page. if this is causing a new browser tab to open, there must be something somewhere else in the code on the page to cause it. this is not being caused by the header() statement. why do you have so much repetition in your code? this just makes for a lot of extra work for you, especially when you need to fix or change anything in the code. currently, you need to add protection against sql injection for all those queries, which there are actually only two different variations of a single query. by refactoring your code so that the sql query statement only exists once, adding sql protection, or changing anything about the query, would only have to be done in one place.
  15. your current database design will only work, using a JOIN query, if each username only has one row in the ca_processed (invoice) table, which would be useless in a real application. in this case, the username does become the value that relates any row(s) in the ca_my_payments table to the one correct row in the ca_processed table. you would however not use SUM(p.total_payment) to come up with the total_invoice amount as that would repeatedly add the amount for each JOINed row between the two tables. if you have more than one row for any username in the ca_processed table, you can use a UNION query to sum up all the invoice amounts and the payment amounts for each username, but i doubt that's your goal.
  16. your code that is executing the sql query statement is not inside the loop. it's after the end of the loop. therefore it is only executing the sql query statement that was formed in the last pass through the loop. wouldn't you have to execute the sql query statement inside the loop?
  17. you do realize that we have no idea what pre-built application you are trying to make work and cannot help you based on the information you are posting. i recommend that you contact the author of the script to get support for it.
  18. does your code use the ldap functions? if not, that error is not relevant.
  19. a JOIN is used when you have related data between the tables. an example would be a user table and your ca_processed table. a query to retrieve user information and his related row(s) from the ca_processed table would use a (LEFT) JOIN query. the user_id, defined in the user table, would be used in the ca_processed table to relate the user's rows in the ca_processed table to the user they belong to. your two tables don't have any defined relationship between them. if you have multiple rows in ca_processed for any username and multiple rows in ca_my_payments for the same username, you will get the result of every row for that username in the first table joined to every row for that username in the second table. if you had an invoice table (which i guess is what your ca_processed table is), that assigned an invoice_id to the invoiced amount and you stored row(s) in a payment table, related to the corresponding invoice using the invoice_id, you would use a (LEFT) JOIN query to get the amount of the invoice and any amounts paid toward that invoice because you now have a defined relationship between the data in the two tables. the reason i mentioned a user table in the example of a join query, is because you shouldn't have usernames/emails duplicated in these two tables. you should have the user information stored in only one place, then use the user_id in any tables holding information that's related to the user.
  20. your post contains no information upon which to help you. all you have done is told us that something doesn't produce the correct output. it would take knowing what conditions are required by the code and what the current values being tested actually are. what troubleshooting have you done to try to find the cause of the problem?
  21. yes, you should dynamically produce the form using the data from the database. a goal to keep in mind when programming, is to try to write general purpose, data driven, code. by storing the questions (which is just some content as far as the computer is concerned) in a database, the questions can be changed, added, and removed simply by changing the data. the code that retrieves and displays the data will remain the same. also, by storing the questions and any options in a database, this assigns identifiers to that information, that you would use when processing/validating and storing the answers (this is shown in the relationships between the tables in diagram that Barand gave.) this results in simpler code, more easy to secure code, the least amount of data storage requirements, and results in the fastest operating design.
  22. in addition to the above problems, you have a fundamental logic error in your code - if($tblnames == 'cryptokeys'){. $tblnames isn't the variable holding each table name inside the loop. see the following much simplified code that should (untested) work - <?php $pdo = new PDO( 'mysql:host=' . DB_HOST_R2D2 . ';dbname=' . DB_DATABASE_DNS, DB_USER_DNS, DB_PASSWORD ); //yoda pdo settings $pdoyd = new PDO( 'mysql:host=' . DB_HOST_YODA . ';dbname=' . DB_DATABASE_DNS, DB_USER_DNS, DB_PASSWORD ); $pdoyd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdoyd->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $tblnames = array('cryptokeys', 'domains', 'records'); // column names per each table $cols['records'] = array('id', 'name', 'type', 'content', 'ttl', 'prio', 'change_date', 'disabled', 'ordername', 'auth'); $cols['domains'] = array('id', 'name', 'master', 'last_check', 'type', 'notified_serial', 'account'); $cols['cryptokeys'] = array('id', 'domain_id', 'flags', 'active', 'content'); //loop through yoda and trunacate all 3 tables foreach($tblnames as $tbl){ echo $sql = 'truncate '.$tbl; echo '<br>'; $pdoyd->query($sql); } foreach($tblnames as $tbl){ echo $query = "INSERT IGNORE INTO $tbl (`".implode('`,`',$cols[$tbl])."`) VALUE (:".implode(',:',$cols[$tbl]).")"; echo '<br>'; $stmt = $pdoyd->prepare($query); $select_results = $pdo->query("SELECT * FROM ".$tbl); while ($row = $select_results->fetch(PDO::FETCH_ASSOC)) { $stmt->execute($row); } }
  23. you need to have php's error_reporting set to E_ALL and display_errors set to ON so that all the php detected errors will be reported and displayed. your sql query statements, at least the first INSERT statement, i stopped looking after that point, are throwing errors, which would result in uncaught exceptions for the posted code. at least the first INSERT statement doesn't contain a correct list of column names or place-holder names and will be throwing sql errors. there are other sql syntax errors in the queries as well. i also recommend that you form your sql query statements in php variables, so that you can echo them to see if the sql syntax is correct. to make the list of column names, you should implode() the array holding the column names, with a comma as the implode separator. you can make the list of place-holder names by using a ',:' as the implode separator. edit: also, when posting code on the forum, please use the forum's bbcode tags (the edit form's <> button) around code.
  24. the error about the header() ... states that some output was sent to the browser and on what line all or the end of that output was at, that's preventing the header() from working. you would need to find and fix what is causing that output.
  25. that stops the reporting of all errors. that should be - error_reporting(E_ALL);
×
×
  • 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.