Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. Perhaps you are having an issue understanding what happens - when. When you set a $_SESSION variable, it is available in the scope in exactly the same way that any other variable is available. It sounds like the issue may be that in your script you output some html, then perform some logic -- set the $_SESSION variable, and this does not change your already emitted html! You need to have a clear idea in your mind about how HTTP works, and how the browser works with the server.
  2. The code you have provided never calls mysql_fetch_array(). That warning is related to some other section of code.
  3. Sounds like a mismatch between the character set of the page and the database table. Are they both UTF-8? Seems like you have one or the other that doesn't match.
  4. This code certainly can not work, because you do not specify that the query return a column named 'Server' in your query. This might help -- without knowing the structure of your CES table, it's not possible to say for sure. $results = mysql_query("SELECT `Name`, `Server` FROM `CES` WHERE `Name` !='' ");
  5. While I appreciate the language barrier, this is fundamentally bad advice. SELECT * does not work faster --- and in many cases it can bring back a lot of data that is not needed or required, which is in no way faster. The best practice is to provide a list of the COLUMNS required. Please also take note that a COLUMN is not the same as a ROW. Since result sets are comprised of Rows and Columns, this is an important distinction when you're talking about relational databases. A query returns a result SET which may contain 0 -> Size of all tables combined ROWS. All rows in the result set have the same number of columns (or fields). Each ROW in the result set needs to be FETCHED from the server.
  6. Maybe this seems like an obvious question, but why would you expect a set of routines that are designed to load an xml file to work ok on a file that contains comma separated values? Putting that question aside... does the server utilize curl? Notice [ if(function_exists("curl_init") ] code in load().
  7. It's not possible to do in any language. You can not disclose data to a device which is not under your complete control, and at the same time control it. With that said, you can certainly make it inconvenient and annoying. Historically these schemes do more to harm their business than help them. If you can be specific about the scenarios involved we might be able to provide some strategies that are sensible without being absurd. For example, in wanting to avoid publically available url's and replayable information, on very effective strategy is to utilize unlock/single use keys to data -- for example, you have a document that someone pays to access. You generate a single use access key. The script that delivers the content requires the access key as a parameter, or as a session variable. The legitimate user is able to access the document some number of times or during the life/duration of the session. This works for documents, images etc. and also insures that the person can't just send the url to other people, or even access it outside whatever window of opportunity you code for. You can also track the date/time and number of accesses. This doesn't of course entirely address your question, but it's food for thought.
  8. You have to read *carefully* the code I originally posted. You just completely left out the setting of the variables at the bottom of the fetch loop. I corrected your code *again*. include "dbcon1.php"; $sql = "SELECT date, price FROM `table1` ORDER BY table.date DESC"; $result = mysql_query($sql) or die(mysql_error()); $my_header= PROFIT ANALYSIS </pre> <table width="70%" border="1" cellpadding="2"></table> cellspacing="2" align="center"><br> <tr> DATE PRICE DIFF </tr> <br>EOD;<br>$my_details = '';<br>$priordate = '';<br>$priorprice = null;<br>while ($row = mysql_fetch_array($result)) {<br> $date = $row['date'];<br> $price = $row['price'];<br> if ($priordate == '') {<br> $priordate = $date;<br> echo $priordate; <br> $priorprice = $price;<br>echo $priorprice;<br> }<br><br>echo $priorprice;// price captured remain as initial price<br> $diff = $priorprice - $price; //PRIORPRICE($priorprice) REMAIN UNCHANGED AS DATE CAPTURED REMAIN THE INITIAL DATE<br> $my_details .= <tr> $date $price $diff </tr> <br>EOD;<br> $priordate = $date;<br> $priorprice = $price;<br>}<br>$my_footer =""; <br> <br>$final = $my_header<br> $my_details<br> $my_footer<br>RESULT;<br> echo $final;<br>?><b
  9. If that is your exact code, I think you'll notice that the last line before the end tag looks like it was accidently pasted in. Try commenting out that line: //SELECT * from recipes r JOIN recipestags rt ON (rt.recipe_id = r.recipe_id AND rc.tag_id = 3)
  10. Post it here like so ... just omit any passwords [code=php:0] Paste code in here [/code]
  11. Adam, are you willing to exert any effort or are you just looking to be spoonfed? If so, this is not the communiity for you. I went and pulled the php script from the tutorial. It is OBVIOUS where you would need to make changes to store the data in a mysql table. Put in some effort and people will help when you have problems. Take a look at the php.net/mysql_query page. //Retrieve form data. //GET - user submitted data using AJAX //POST - in case user does not support javascript, we'll use POST instead $name = ($_GET['name']) ? $_GET['name'] : $_POST['name']; $email = ($_GET['email']) ?$_GET['email'] : $_POST['email']; $website = ($_GET['website']) ?$_GET['website'] : $_POST['website']; $comment = ($_GET['comment']) ?$_GET['comment'] : $_POST['comment']; //flag to indicate which method it uses. If POST set it to 1 if ($_POST) $post=1; //Simple server side validation for POST data, of course, //you should validate the email if (!$name) $errors[count($errors)] = 'Please enter your name.'; if (!$email) $errors[count($errors)] = 'Please enter your email.'; if (!$comment) $errors[count($errors)] = 'Please enter your comment.'; //if the errors array is empty, send the mail if (!$errors) { //recipient - change this to your name and email $to = 'Your Name '; //sender $from = $name . ' '; //subject and the html message $subject = 'Comment from ' . $name; $message = ' br /> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> Name' . $name . ' Email' . $email . ' Website' . $website . ' Comment' . nl2br($comment) . ' '; //send the mail $result = sendmail($to, $subject, $message, $from); //if POST was used, display the message straight away if ($_POST) { if ($result) echo 'Thank you! We have received your message.'; else echo 'Sorry, unexpected error. Please try again later'; //else if GET was used, return the boolean value so that //ajax script can react accordingly //1 means success, 0 means failed } else { echo $result; } //if the errors array has values } else { //display the errors message for ($i=0; $i'; echo 'Back'; exit; } //Simple mail function with HTML header function sendmail($to, $subject, $message, $from) { $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers .= 'From: ' . $from . "\r\n"; $result = mail($to,$subject,$message,$headers); if ($result) return 1; else return 0; } ?>
  12. 1. Mysql offers byte size integer types. Each type matches the number of 8 bit bytes used to store them: tinyint: 1 byte smallint: 2 bytes mediumint: 3 bytes int: 4 bytes bigint: 8 bytes What this implies requires an understanding of basic binary math. For example in one byte, the largest value that can be represented is 255. This allows for values form 0-255 to be represented. In 2 bytes that goes to 65767 and on up. Usually you have a good idea of the min and max values you might expect in the lifetime of your system. Being cautious and using the smallest data type that fulfills the design is a good strategy, as the size of data is the #1 performance issue related to good db design. The numbers inside the quotes --- ie int(4) should be avoided. They only come into play if you use ZEROFILL, and I have never had cause to use ZEROFILL in a db design. 2. I don't see the value of using an enum. It's a non standard data type at best, and at worst violates one of Codd's rules for relational design. You don't save any space, as an enum still uses a byte. Sure there's a small amount of protection in that if you only want 0 and 1, it won't let you insert a row with 3, but for true enumerated lists, you're better off having the real implied foreign key table. Then later if you need a new value in the enumerated list, you add a row vs. alter the database structure. 3. An MD5 in string form is going to be 32 characters. It will never be less, so there's no reason not to use a CHAR(). I'm not sure there's a performance advantage, although there might be. A CHAR allocates the entire number of characters for storage even if some of the characters are not used, unlike a varchar() which only allocates what it needs. It makes sense in this case, that you use a CHAR since you'll always use every character, and it would make sense that in this case, mysql may be able to optimize storage and retrieval knowing that the column size is fixed. 4. For any integer if you do not specify UNSIGNED it reserves half the available space for negative values. So for a tinyint you can store -127 .. 0 .. 127. For Keys that are filled using AUTO_INCREMENT, you always want them to be UNSIGNED because the keys will be allocated as positive integers -- otherwise you risk losing half your available rows for values that will never be utilized.
  13. Your question doesn't make much sense. It sounds like you might be looking for data that could be loaded into one or more tables. I don't know where you might be able to get data like that off the tip of my head.
  14. Check for a php error file -- location would be indicated in phpinfo(). With that said, I'd just check your code. If it isn't a huge script paste it here inside the php bbcode blocks.
  15. Actually MySQL is much more permissive than one might think, in terms of the use of keywords for column names. You don't really need the bactics around the name in this query... it will work ok without them, although your advice is great.
  16. There's no need to involve PHP in the query when you can use mysql directly. I've written several articles that include examples of how to do this. http://www.gizmola.com/blog/blog/archives/51-Exploring-Mysql-CURDATE-and-NOW.-The-same-but-different..html SELECT * FROM courseDates WHERE date
  17. No when you get a T_STRING error it means that your php syntax is incorrect. Often you are missing a required semicolon, endquote, end brace or any of the myriad details. A decent editor that does color syntax highlighting will often help you see the issue. Check your error log for the actual error message.
  18. No, the scripts I provided can be run in a sql window in phpMyAdmin.
  19. You do it... at the very bottom you should see a Green button that says "MARK SOLVED".
  20. No ... the loop was setup properly in my example, you can not arbitrarily move braces around and have the same effect. Let's see the actual code of the script you have at this point. Please use the [code=php:0] php code here .... [/code] on each side of your php code block.
  21. So --- as you can see, you have a result set of 13607 rows being joined N times. This isn't going to be fast. You may be able to get it to stop using the temporary table and filesort by hinting the use of the appropriate index and see if that significantly improves the performance: http://dev.mysql.com/doc/refman/4.1/en/index-hints.html
  22. session_id() has to be called before session_start().
  23. If your server is running in safe_mode, the exec related commands are disabled. Also individual functions can be disabled via the php.ini file, using the disable_functions directive. You should look at the output of phpinfo() to see if there are restrictions in place. Your code should work fine on a server that doesn't have some sort of restriction in place.
  24. Most people use curl to scrape web information, since it was primarily designed for http. Previously the answer would have been, absolutely not with curl. The latest version of curl now supports smtp, but that support might not be available in the php api. You certainly don't need curl to do smtp with php, as there are various packages out there beginning with the ones in PEAR that let you do mail queueing and smtp. For example, phpclasses purports to have a couple of classes that will allow for this. http://www.phpclasses.org/blog/package/9/post/1-Sending-email-using-SMTP-servers-of-Gmail-Hotmail-or-Yahoo-with-PHP.html
  25. Your example uses: $def->defence without any prior reference to where that values comes from or what it is. Your variable $defarmdef isn't explained. You also retrieve one weapon... so does that mean that there's no dual weilding? If you really want any feedback on this, you have to provide some background about the stats and what your intention is. Otherwise, you have some equations ... if they work alright I guess it's ok, but I'm not sure what the algorithm is you're working with or if there's anything I could suggest to you that might be an improvement.
×
×
  • 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.