Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,449
  • Joined

  • Days Won

    174

Everything posted by mac_gyver

  1. most of the errors are follow-on errors. they are caused because your database connection failed, but you didn't detect that in your code and stop your code from running and trying to use the non-existent connection. so, your code actually needs to test if the database connection worked before trying to run any query AND your code needs to test of the query worked (didn't fail due to an error) before trying to use the result from that query. this will eliminate most of the errors and just leave the most import error that started the whole problem. as to why your database connection is failing, it's because you/your-server has too many connections open and no more are permitted. this is typically caused by a server that has too many accounts hosted on it and doesn't permit enough database connections and/or i/we regularly see this problem when one script repeatedly opens and closes database connections, rather than just opening one connection and use that one connection for the duration of the script (i have a post somewhere on this forum theorizing that because it takes some time for the database server to actually close a connection and reduce the count of open connections, that a poorly written script that that opens and closes the database connection several times during its execution ends up consuming multiple database connections.) your code should NOT open a database connection, use it for one operation, then close the database connection. you should open one database connection and leave it open until you are completely done with it, then close it or simply let php automatically close it when the script ends. edit: your code is also mixing mysql (no i) and mysqli functions, has some @ error suppressors in it, and a lot of class methods simply wrap one php statement, and a lot of the functions are not using the proper parameters. in short, this code looks like it was thrown together with little planning and should be started over.
  2. the $_FILES array is the information about the file when the file was uploaded. the $_FILES array doesn't exist after that point. what method have you used to associate the row in the product database table with the image that was stored in the $frontpage_url."/images/" folder?
  3. cannot really help you without specific information. the general answer to programming questions is yes, you can do just about anything you want if you write the code that does it. is this xml data intended to be directly imported into a database (it must be in a specific format, as shown at the link to the documentation that i posted above.)
  4. between the two php help sites that you have posted this on (that i know of, there could be more) you have gotten three replies that show essentially the same method of producing the xml. in each case, someone defined some input data, because your query and code doesn't show anything or how it relates to the xml (your code doesn't even attempt to do anything in the while(){} loop with the data) then they produced the xml from the point of having the data that the xml implies it would need. if you take the example code i posted in reply #2, and change the input data to the following, it produces EXACTLY the xml that you stated you want in reply #3 - $data[] = array('channel_id'=>'row1','display_name'=>'row1','program_id'=>'','start'=>'','stop'=>'','title'=>'', 'sub_title'=>'','description'=>'','category'=>''); $data[] = array('channel_id'=>'row2','display_name'=>'row2','program_id'=>'','start'=>'','stop'=>'','title'=>'', 'sub_title'=>'','description'=>'','category'=>''); $data[] = array('channel_id'=>'row3','display_name'=>'row3','program_id'=>'','start'=>'','stop'=>'','title'=>'', 'sub_title'=>'','description'=>'','category'=>''); your task is to write the sql query that retrieves that data, based on the columns you have in your database table, and makes it available to that code. no one in the help forums you have been posting is going to fix your code and post a working copy/paste solution for you to use, for two reasons - 1) the code you posted doesn't show any attempt and it doesn't show the needed information or how it relates to the xml fields, and 2) if you want someone to fix your code, hire someone and pay them to do this for you. programming help forums are not about writing or finding code for you to copy/paste.
  5. currently, your mysqli_query() statement is missing the $conn parameter, which would be producing a php error like - Warning: mysqli_query() expects at least 2 parameters, 1 given in your file... your previously posted code correctly used mysqli_query(). you seem to be just randomly changing code without any reason. programming like that rarely leads to a solution and makes it very difficult to help when the problem is a randomly moving target.
  6. it doesn't matter how many times you may have used any specific code. what matters is the code is currently failing and until you troubleshoot it and determine why it is failing, it won't get fixed. you need to find out why the query is failing by using mysqli_error, correctly, with the $conn variable as a parameter and without the $conn variable as part of a string.
  7. the original error message is because you are putting the $conn variable into a string context - trigger_error("Query Failed! SQL: $conn - Error: ".mysqli_error(), E_USER_ERROR); i suspect you intended to put the variable holding the sql query string at that point. you do however need to use $conn in the msyqli_error($conn) statement. next, the query is failing because the $i variable is either empty or is a string, it is being used in the query as though it is a number, resulting in invalid sql syntax. you would need to both determine exactly what is in $i and you should be validating it so that you don't even attempt to run the query unless you know $i contains an expected type of data. lastly, in looking at your function definition. you should NOT form a database connection inside a function to run one query. your application should form the database connection and pass it into any function/class that in dependent on a database connection.
  8. your xml definition doesn't make complete sense (there's no program id for example) and your query is not retrieving the data that the xml needs. each row in your tvguide table should correspond to one program. the id should be the program's id and there should be a channel id or channel number and a start, stop, title, sub-title, description, and category(id) value. the channel id and the channel display-name should be stored in a separate table and join'ed to the tvguide table in the query to get the channel display name. the same would be true for the category id and category name. your query should get the data you want in the order that you want it, with the field values that you need to build the xml. the logic forming the sql query and running it should all come first. the code producing the xml should be general purpose (it doesn't care how many channels or how many programs there are under each channel.) unless you are editing existing xml, there's little need for manipulating the xml nodes/attributes... directly, just output the xml tags at the appropriate place when you are iterating over the data. the following example shows how, after you have retrieved the data from the query (in an array named $data), that you can produce the xml output - <?php // fake some example data. the actual data would be retrieved from a database query $data[] = array('channel_id'=>10,'display_name'=>'channel 10 name','program_id'=>123,'start'=>'s1','stop'=>'e1','title'=>'program title', 'sub_title'=>'sub title','description'=>'program description1','category'=>'some category'); $data[] = array('channel_id'=>10,'display_name'=>'channel 10 name', 'program_id'=>456,'start'=>'s2','stop'=>'e2','title'=>'program title', 'sub_title'=>'sub title','description'=>'program description2','category'=>'some category'); $data[] = array('channel_id'=>15,'display_name'=>'channel 15 name', 'program_id'=>789,'start'=>'s1','stop'=>'e1','title'=>'program title', 'sub_title'=>'sub title','description'=>'program description3','category'=>'some category'); // build the xml $xml = '<?xml version="1.0" encoding="UTF-8" ?> <tv generator-info-name="www.mysite.com/xmltv">'; $last_channel = null; // used to detect when the channel changes foreach($data as $arr){ if($last_channel != $arr['channel_id']){ // the channel changed if($last_channel != null){ // not the first channel, close out the previous channel $xml .= '</channel>'; } // start a new channel $xml .= "<channel id=\"{$arr['channel_id']}\">"; $xml .= "<display-name>{$arr['display_name']}</display-name>"; $last_channel = $arr['channel_id']; } // output the program info under each channel $xml .= "<programme channel=\"{$arr['channel_id']}\" start=\"{$arr['start']}\" stop=\"{$arr['stop']}\">"; // i don't see a program id in this definition, but it likely needs one $xml .= "<title lang=\"en\">{$arr['title']}</title>"; $xml .= "<sub-title lang=\"en\">{$arr['sub_title']}</sub-title>"; $xml .= "<desc lang=\"en\">{$arr['description']}</desc>"; $xml .= "<category lang=\"en\">{$arr['category']}</category>"; $xml .= "</programme>"; } if($last_channel != null){ // close out the previous channel if any $xml .= '</channel>'; } $xml .= '</tv>'; // output the xml to the browser in this example, if you want to store it to a file, just write $xml to a file here... header("Content-Type: text/xml"); echo $xml;
  9. i recommend reading the mysql documentation for what you are doing - http://dev.mysql.com/doc/refman/5.5/en/load-xml.html based on what i know, you will need to use - ROWS IDENTIFIED BY '<doc>'
  10. $_SERVER['DOCUMENT_ROOT'] is a file system path. it only has meaning on the server where it is at. it is NOT usable in the html on your page. the links in your html must be URLs that are either relative paths to the domain root or the page they are on or an absolute url. links that are built using $_SERVER['DOCUMENT_ROOT'] will work on your localhost development system since the browser is also running on that system and can request the file through the file system. for an absolute URL, i.e. http://somedomain.com/some_path/some_file.php or http://localhost/some_path/some_file.php, the browser uses that url as is in the http request to the server. for relative URLs, a domain relative url looks like - /some_path/some_file.php. the leading slash refers to the document root. the browser takes the current page's http://somedomain.com or http://localhost and appends the domain relative url to it. for all other relative URLs, i.e. some_path/some_file.php, the browser takes the current page's http://somedomain.com/some_other_path or http://localhost/some_other_path and appends the relative url to it.
  11. did you read the error messages? you have output on line 12 of connect.php. that line is the closing ?> tag. you likely have some characters after the ?>.
  12. the current list of undefined constant... errors indicate you have a mix of quotes or no quotes around the values being mentioned.
  13. the first thing that is apparent is, wherever you copy/pasted the code from originally, it was published using curly/smart-quotes and is invalid php code. quotes inside of php code must be straight " quotes. it would probably help if you showed us what you got, as that would narrow down some of the possible causes.
  14. when all you do is post the list of the requirements for your assignment, without asking a specific question, you won't get any help on a programming help forum. programming help forums are for help with code you have written, or an error with code you have written, or for specific programming questions. do you have any code or error you need help with or do you have a specific question?
  15. a) don't hijack other peoples threads, use your existing thread b) in your own thread for this problem, you didn't state you want to find the maximum value for each column. you stated you wanted to find the maximum (the title), the minimum (in the thread), for a particular column. you need to clearly state what you are trying to find.
  16. a) how large is the file, how many rows of data does it contain? b) does the file contain properly formatted <row></row> elements that mysql would be able to use by default to find the data?
  17. the problem is because the new-line character on the end of each line is being stored in the $todos array. this is causing the min/max to treat the values as strings. use the trim function to remove the new-line characters - $valor=trim($datos[count($datos)-1]); you could also use the FILE_IGNORE_NEW_LINES flag in the file() statement.
  18. for something simple, that requires no more than a few settings, use a php array in a .php file. provide an installation script that builds the .php file or instruct the user to edit the file to set the settings. simply including the file and use the array entries. for something with more settings, where you would provide an interface to allow editing the many settings, store the configuration in a database table (you will still need a minimal .php config file to hold the database credentials.)
  19. your reply above doesn't provide any additional information and contains nothing i asked about. without even seeing your code that runs the query, i can tell it does not have any error checking logic in it, and the php error you are getting is a follow-on error because you allowed your code to try to fetch data from a query that failed with an error of some kind. it doesn't matter how long your code may have previously worked. it requires finding out why it is failing now in order to find the cause to fix it. until you add some logic to your code that tells you the output from sqlsrv_errors() when the query fails, you will never discover what is causing the problem.
  20. the line in question is a property declaration. you cannot use any php 'operators' or functions in a declaration as the definition must be completely defined at the time the code is parsed (operators/functions are evaluated at runtime.) from the php.net documentation - // invalid property declarations: public $var1 = 'hello ' . 'world'; public $var2 = <<<EOD hello world EOD; public $var3 = 1+2; public $var4 = self::myStaticMethod(); public $var5 = $myVar; the values you are trying to assign to your $_config and $_parse properties would need to be done using php code in the constructor.
  21. the error message and a few lines of code leading up to the line with the error would help. the reason .ini (and .xml) files don't get used for configuration settings in applications that are meant for others to use is, without specific security in place that prevents access to those files, anyone discovering them (or learning of their existence because they are used in a open-souce/published script) can simply request them through the browser and see all the settings they contain. the content of .php files, on the other hand, are automatically secure as the php code in them cannot be seen when or if they are browsed to. it would take breaking php on the server to be able to request a .php file and see the contents in it.
  22. it means your query failed due to an error and returned a false value or you could be using a wrong variable name or there's a problem in your code and this error was always occurring but was hidden and what changed is that the php error_reporting level got changed. does your code that is running the query contain any error checking logic in it so that you would know if the query is producing an error, and if so, what is the output from sqlsrv_errors()?
  23. it's possible that your actual column names have different capitalization between the two servers. what does using the following - print_r($row);, immediately after the $row = mysql_fetch_array($res); statement show?
  24. the Uncaught exception is because you have spelling error in -- catch(PDOExceptoin $ex) the error in the query is because key is a reserved mysql keyword. either rename the column to something else or enclose key in back-ticks `key`
  25. when you tried this, your debugging print_r($_POST); statement should have given you a very good clue about what your code needs to loop over - Array ( [approval] => Array ( [1] => Yes [3] => No [4] => Yes [6] => ) ... $_POST['approval'] is an array, where the index is your database table's 'Index' and the value is the Yes, No, or empty value that was selected for each 'Index'.
×
×
  • 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.