Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. w3schools does not contain any mysqli specific infomration. When using mysqli_insert_id() procedurally, the connection parameter is required. In the code you posted, you are NOT executing the query, so mysqli_insert_id() will always return zero. From the php.net documentation -
  2. You have an error in your code, somewhere around line 42.
  3. Which SQL server type? Also, posting an example showing what you are doing, what result you are getting, and what result you expect would help. In mysql the only 8 byte date/time is a DATETIME data type and referencing it in a string context returns a 'YYYY-MM-DD HH:MM:SS' string. Referencing it in a numerical context returns a YYYYMMDDHHMMSS value.
  4. I recommend that you set up a local development system with the same php.ini settings as your new host (short open tags OFF, register_globals OFF, ...) AND set error_reporting to E_ALL (or to a -1) and display_errors to ON in your master php.ini and get your code to work on the development system first. You will save a ton of time because you won't need to keep uploading files to your server to see the result of each change and having the error_reporting/display_errors settings set as suggested will get php to help you by pointing out all the things in your code that are no longer defined because they were dependent on register_globals. Edit: you should also use $_SERVER['DOCUMENT_ROOT'] to get the runtime path to your document root folder so that you don't need to keep editing a bunch of path statements in your code should you ever move to a different server again.
  5. If you do a 'view source' of the print_r() output, you will see why you are seeing the results that you are.
  6. If you do a search on that error message, you will find that it means that your query failed due to an error of some kind. For debugging purposes, use the following error checking on your query - $check_connect = mysqli_query($dbc, $check_query) or die(mysqli_error($dbc));
  7. There's not even 44 lines in any of the posted files.
  8. You would return an array with the pieces you want as elements in the array.
  9. To format your HTML output the way you want, I recommend some basic HTML tutorials - http://w3schools.com/html/default.asp The following sections at the above link would be relevant - HTML Headings HTML Paragraphs HTML Formatting HTML Styles HTML Tables
  10. You might want to make your use of <td></td> elements different as what you posted would just keep adding table data elements to a single row in your table. Either eliminate all the table elements or put the Category in <tr><th> ... </th></tr> elements and put the Title <tr><td> ... </td></tr> elements.
  11. To produce your desired output using your original query, you would simply 'remember' the current category and output a new category heading every time the category changes - <?php // execute query here $last_category = ''; // initialize to a value that will never exist in the data while($row = mysql_fetch_array($result)){ // test if the category changed if($last_category != $row['Category']){ // the category changed (or is the first one), output the $row['Category'] heading here... $last_category = $row['Category']; // 'remember' the new category value } // output the $row['Title'] data here ... } ?> In general, your query (one) should retrieve the data you want, in the order that you want it, and your presentation code should simply iterate over the data and display it the way you want.
  12. You should be using a DECIMAL data type to store your values AND you are probably doing something in your php code that treats the number as a floating point value which results in a floating point conversion error. What's your actual code that is retrieving and displaying the value?
  13. Based on the code you posted ^^^, you are overwriting the first instance in $publisher with the second instance.
  14. The WHERE clause you added to the UPDATE query, wasn't actually a part of the query.
  15. I recommend trying some quotes around the correct setting.
  16. Since there are no startup errors concerning loading the .dll's, it is most likely that php cannot read the php.ini or it cannot see the two lines that should be loading the mysql/mysqli .dll's I'm going to guess that either when you edited php.ini it got saved as php.ini.txt and you have file extensions hidden or you have a syntax error in your php.ini that is preventing the two lines from being seen as valid settings (does changing any other setting in the php.ini affect the phpinfo() output) or you have a file/folder permission problem and php cannot read the php.ini.
  17. When a client makes a HTTP request to a server for a page, that page is output/echoed back to the client. Ref: http://en.wikipedia.org/wiki/HTTP
  18. Does the phpinfo() output show a mysql and/or mysqli section? I thought you stated you installed the three pieces into the 'program files' folder? What is the php.ini and the ext folder doing in c:/php ? The mysql server is a service. Php connects to it on Windows using a TCP/IP connection. As long as the mysql server is running and can be connected to it does not matter what the underlying architecture is.
  19. You output an xml document to whatever client requested the page/document. If you are simply browsing to the page, you should expect to see the xml being rendered in the browser.
  20. You need to make sure that the php.ini that you are changing is the one that php is using. Create a .php file with <?php phpinfo(); ?> in it and browse to it. The Loaded Configuration File value is the php.ini that php is using. Once you get php to use the php.ini that you are changing, you need to set the php.ini extension_dir setting to point to the folder where the extension .dlls are at. You also need to check that the actual .dll files are present (in programming you cannot assume that something is the same as what you did before, you must check and confirm that it is the same.) Have you checked your web server error log file to see what sort of startup errors are occurring for the mysql/mysqli dll's? Beyond getting all the pieces in the right place, problems loading extensions are usually due to file system user permissions. Do all the files (httpd.conf, php.ini, dll's) and folders have permissions set so that the user that apache is running under can access them?
  21. How did you install PHP? The .msi installer or manually using the .zip package?
  22. The class definition must be included before the session_start() statement AND $_SESSION is the actual session variable array. You would need to use a specifically named session variable, something like - $_SESSION['user'] = new session("ttocskcaj",84824526893564);
  23. The code you posted has some problems - 1) You need an exit; statement after your header() redirect to prevent the remainder of the code on your page from executing while the browser is preforming the redirect. Your current code is still executing the query when $_GET['id'] is empty or when $_GET['id'] contains things like alpha strings (i.e. someone trying to inject sql.) You will need to use {} in your if(){} statement to encompass the header() and exit; statements. 2) You are using the original $_GET['id'] value and not the sanitized $ID variable in your query, so $_GET['id'] can contain things that start with a numerical term but also contain injected sql. 3) You don't have any error checking, error reporting/logging, and error recovery logic in your code, to 1) Check if the query worked or failed, 2) Output a user error messaged (i.e. an error occurred that prevents this page from being accessed) and log the relevant information about the error, and 3) take an appropriate action if an error occurred (recover from the error) by preventing any follow-on errors due to accessing a non-existent result resource.
  24. To get the best answer, you would need to post the code from the point where you are forming and executing the query through to the end of the loop that is retrieving the data, but the most common reasons for that error are - 1) A query that is failing due to an error (perhaps you are not escaping string data and sql special characters in the data is causing an sql syntax error or you are expecting numerical data but are receiving an alpha string as data...) 2) You are overwriting the $result resource variable in your code. If the problem is due to item #1, it also means that your code is not checking if the query worked or failed before you attempt to access the result set the query returned and it could also mean that you are not properly validating and escaping the external data that your script receives. If any query is failing due to an error, you should not execute follow-on code that is dependent on the result of that query AND your script should be logging the actual mysql_error() that occured and the actual query string so that you would have a record of what is failing so that you can fix it.
  25. Actually, php.net just added it in php5.3 so that php help forums like this one will get more traffic
×
×
  • 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.