Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. You already have an active thread for this. Don't start another one.
  2. current_time, the point in the query that is being called out in the error message, is a reserved mysql keyword. You either need to rename your column or enclose that in back-ticks `` every time you use it in a query.
  3. You don't have any white-space after the function keyword.
  4. I recommend forming your query in a variable, such as $query, so that you can echo it to see what it actually contains. You should also be escaping the data values being put into the query (you likely have some data with single-quotes and commas that are causing the error.)
  5. Untested, but should work - $sql = "SELECT DISTINCT MONTHNAME(blog_date) as blog_month, YEAR(blog_date) as blog_year FROM subarc_blog ORDER BY blog_date";
  6. No, from the mysql documentation -
  7. Not every forum section is setup up to add to the post count. This is to help prevent members from posting nonsense just to increase their post count.
  8. Php variables are case-sensitive and $_SESSION is all upper-case. You also need a session_start(); statement on any page that sets or references a $_SESSION variable, before any $_SESSION variables.
  9. I was going to suggest that it sounded like $dzone was 100. When your code does not produce the results you expect, you should always check what values your code IS using because we would need to know that as well in order to tell you why your code is producing the unexpected results.
  10. Yes you can do this using php/mysql. In fact, if you do it all in javascript, the answers will be available in the source code and it would not be much of a quiz because everyone can find the answers simply by looking. Browsers (clients) and web servers don't interact the same way that an application runs on a local computer. They operate on a request/response basis. The client makes a HTTP request. The web server does its best to find what was requested and send out a complete response to that request. Then the web server goes onto service other HTTP requests. As thorpe stated, this process is stateless. The web server does not know or care about any request that occurred before the current one or what will occur after the current one. If one of your pages is a form, the web server is not sitting there specially waiting for that form to be submitted after it has been requested. It is either servicing other HTTP requests or in an idle loop. So as thrope stated, your first post in this thread is not how browsers/web servers interact. There is no waiting involved. A script does not loop through a set of data, outputting a question and waiting for an action in the browser before continuing with the next iteration of the loop. To make this stateless process have the ability to 'remember' where each visitor is at in a process like a quiz, you would use session variables to remember the current state on the server.
  11. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=313970.0
  12. You need to create an element and append it to document. You are currently rewiring the innerHTML. Since your question is actually a javascript question and not a php question, moving this to the correct forum section...
  13. Perhaps it would be better if you asked your server administrator what methods they do permit. Asking us would just be a guessing game.
  14. Your fopen() statement is missing the second parameter. You should be developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON so that all the php errors in your code will be reported and displayed. You will save a ton of time.
  15. Programming help forums can really only help with specific questions, specific problems, or specific errors with code that you can post. If you have a script that you are using, you can post the relevant sections of it, along with a specific question, problem, or error you are having with it and likely get some help in a programming help forum.
  16. What you are attempting to do is to write a script to Create, Read, Update, and Delete (CRUD) database information. There are countless php scripts/classes and tutorials posted all over the Internet that you can either use or look at to learn how you can do this.
  17. You would need to produce a value where the same position in each string has the same significance. That would require that every field making up the value has the same length. You could then directly compare the values as strings (even with the : and + still in them) because each character position in a string has the same significance/magnitude as that same character position in the other string(s). What are the maximum number of possible digits for each number within that data? You are implying 2 (the :13, :14, and +13) Edit: The short answer would be if you were to include leading zero's on each number/field making up the values when they are stored, so that each stored value has the same length/format, you could ORDER BY them directly.
  18. I'll guess a fatal parse or fatal runtime error, due to something in the code that was not posted. Are you doing this on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that all the php errors that your code produces would be reported and displayed? You will save a ton of time.
  19. Are your rewrite rules domain specific and you switched domain names? Frankly, you have not posted any actual information in this thread that would allow someone to directly help you with what you are doing and with what could be causing the symptoms.
  20. The following is some minimal code that accomplishes what you are trying to do, even addressing the duplicate key error that started this thread. The html/form is basically what you posted with the items that I did not have taken out/hard coded. Enjoy - <?php include "../lang/english.php"; include "../config/config.php"; $errors = array(); // condition and map inputs $fields = array('site_name'=>'sitename','site_email'=>'email','your_name'=>'name','meta_description'=>'meta-description','meta_keywords'=>'meta-keywords'); foreach($fields as $var => $field){ $$var = isset($_GET[$field]) ? trim($_GET[$field]) : ''; } // check if the form was submitted if(isset($_GET['submit'])){ // connect to/select database mysql_connect("$db_hostname", "$db_username", "$db_password") or die(mysql_error()); mysql_select_db("$db_database") or die(mysql_error()); // basic validation (not empty) and escape data foreach($fields as $var => $field){ if(empty($$var)){ $errors[] = "The form field: $field, is empty!"; } // escape the data $$var = mysql_real_escape_string($$var); } // if no validation errors, insert the data if(empty($errors)){ $insert = sprintf("INSERT INTO settings (site_name, description, keywords, email, name) VALUES ('%s','%s','%s','%s','%s')", $site_name, $meta_description, $meta_keywords, $site_email, $your_name ); if(!mysql_query($insert)){ // a query error occurred // check if due to duplicate data if(mysql_errno() == 1062){ // 1062 = duplicate primary key error (your error number might be different depending on your table definition) $errors[] = "The site name: $site_name, already exists and cannot be inserted!"; } else { // all other query errors - $errors[] = "A database error occurred and your query cannot be processed!"; trigger_error(mysql_error()); // use error_reporting/display_errors/log_errors to display/log the error condition } } else { echo "The site name: $site_name, was successfully inserted!"; } } } ?> <!DOCTYPE html> <html> <head> <title><?php echo $site_name; ?> :: :: Powered by osPHPSite</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <link href="css/admin.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="main"> <div id="middle"> <div id="center-column"> <div class="table"> <?php if(!empty($errors)){ echo 'The following errors occurred:<br />'; foreach($errors as $error){ echo "$error<br />"; } } ?> <form action="" id="settings" name="settings"> <table class="listing form" cellpadding="0" cellspacing="0"> <tr> <th class="full" colspan="2"></th> </tr> <tr> <th colspan="2"></th> </tr> <tr> <td>Site name: </td> <td><input type="text" name="sitename" value="<?php echo $site_name; ?>" width="172" /> <em>Site name for logo</em></td> </tr> <tr> <td>Email: </td> <td><input type="text" name="email" value="<?php echo $site_email; ?>" width="172" /> <em>Your email address</em></td> </tr> <tr> <td>Name: </td> <td><input type="text" name="name" value="<?php echo $your_name; ?>" width="172" /> <em>Your own name</em></td> </tr> <tr> <td>Meta Description: </td> <td><input type="text" name="meta-description" value="<?php echo $meta_description; ?>" width="172" /> <em>SEO</em></td> </tr> <tr> <td>Meta Keywords: </td> <td><input type="text" name="meta-keywords" value="<?php echo $meta_keywords; ?>" width="172" /> <em>Separate with Commas</em></td> </tr> <tr> <td><input type="submit" class="button" name="submit" value="Submit"></td> </tr> </table> </form> </div> </div> </div> </div> </body> </html>
  21. <?php $path = "images/folder/something/maybeanotherone/file.ext"; $parts = explode('/',$path); $last = count($parts) - 1; // the index starts at zero $filename = $parts[$last]; // you can also use end($parts); unset($parts[$last]); // remove last element (filename) foreach($parts as $part){ if(!is_dir($part)){ mkdir($part); echo "Made: $part<br />"; } chdir($part); // make current working directory be the current part of the path } ?>
  22. Use count to get the number of elements. You can then get the file name from the last element and remove that element from the array before you iterate over the folder names.
  23. Use explode to break it into it's parts, in an array. Use a foreach loop to iterate over the parts in the array.
  24. Does your new host support URL rewriting? .htaccess is Apache specific. Is the web server an Apache server with the mod_rewrite module installed?
  25. If you were to post actual code that produces the symptom, I'm sure someone can help you. It sounds like invalid HTML to me.
×
×
  • 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.