Jump to content
Old threads will finally start getting archived ×
🚨🚨 GAME-CHANGING ANNOUNCEMENT FROM PHP FREAKS 🚨🚨 ×

ChatGPT 🤖

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

Everything posted by ChatGPT 🤖

  1. Thanks for all your replies I've changed a few things around, and I've now implemented the layout properly with my PHP/MySQL code. There's still lots of changes to be made (although I consider the homepage pretty much complete), but I'm pretty close to completion. Any more advice from you guys? Thanks Note: the site is now at http://www.designersvault.net rather than http://www.designersvault.net/new
  2. Thanks for your reply I've got the bad habit of using internal stylesheets then moving to an external one later, so that'll be changed soon. Ah yes upon testing in other browsers I've noticed the problem with the Designers Vault text too, I think it's because I was messing around with the letter spacing . I'll use your advice to help improve it, thanks.
  3. Hi, I'm currently creating a new design for my website, Designers Vault and I'm wondering what people think so. Here's the link: http://designersvault.net/new/ It's not finished yet, but what do you guys thinks so far? Is there anything you'd add/remove/change? Thanks
  4. Thanks
  5. Thanks, that works great just one last question - I'd like to be able to fully comprehend what the program does (I'm not completely familiar with PHP) so can I just ask what the $exponent >>= 1 and $exponent & 1 signify? I'm not familiar with these expressions. Again, thanks very much.
  6. Right, I just figured out that my method that I'm using seems completely wrong So I guess a final question (which has nothign to do with PHP, sorry:p) is how would you break down these equations so they are easy to perform? For example I also have to do 2668^3473 (mod 5063) which would of course prove impossible by hand...Thanks
  7. Thanks for your reply again, I've just tested that and it works perfect so thanks this is for coursework though and we are required to understand the theory that when carrying out modular exponentiation that after every power/multiplication, if you mod the number by the modulus you are using, and carry out the next multiplication on the newly 'modded' number, and repeat that until you finish all the multiplications required in the exponentiation. So to perhaps show that I understand the theory I'm wondering if it's possible to do it that way in PHP... For example, in this 614^17 mod 5063... 1: 614 * 614 = 376 996 376996 mod 5063 = 2334 2: 2334 * 2334 = 5447556 5447556 mod 5063 = 4831 And carry this out 17 times in total, after all the exponentiation is done. If I'm being completely confusing no worries, as the code you gives works fine I could just use that
  8. Thanks for your reply, I'm just testing the BCMath extensions now as they are installed on my server. But, I'm a bit as I am using this method of exponentiation because it uses significantly less memory (after every multiplication, it applies mod 5063 to that number, then carries out the next, modding that number too...etc), and I was told in theory the PC should never have to compute large numbers at once with this method. Or perhaps I'm just thinking of it wrong EDIT: BCMath returns the same wrong result...but, I've noticed something rather stupid in my code. I was multiplying $num1 by $num2 which was wrong, as it should be simply $num1 * $num1 - I've amended this but still have the wrong answer...is there anything else I've missed? Thanks
  9. Hi, sorry for the large amount of posts lately but I need more help I need to be able to work out very large powers with mod n - so for example, at the moment I'm testing 614^17 (mod 5063). So far I have this script: <?php $num1 = 614; $num2 = 17; $mod = 5063; $answer; for ($i = 0; $i < $num2; $i++) { $answer = $num1 * $num2; $answer = $answer % $mod; $num1 = $answer; } echo $num1; echo "<br />"; echo $num2; echo "<br /><b>"; echo $answer; ?> However, I've calculated the value that the answer should be, and verified it with others, and the server is not outputting the correct values. The answer should be 2668, but the server does not return this value - I've also tried changing the < $num2 in the for loop to <= $num2, etc but to no avail. Any ideas? Thanks
  10. Thanks for your replies I've currently been adapting the code to work with my current prime algorithm, just to stay consistent - I have the following <?php $num = $_POST['number']; $factors = array(); $i = 0; if ($num > 0 && $num < 10000) { for ($check = 2; $check <= sqrt($num); $check++){ if ($num % $check == 0){ $factors[$i] = $check; $num = $num / $check; $i++; } } if (count($factors) == 0) { echo "Number is prime"; } else { echo "Number is not prime! Factors are listed below"; for ($counter = 0; $counter < $factors[$counter]; $counter++) { echo "$factors[$counter] x "; } } } else { echo "Number is not between 0 and 9999!"; } ?> But it doesn't work correctly...rather than factorising as 2 * 2 * 2 * 5 * 13 as it should, it just comes out as 2 * 4 * 5...sorry to be a pain with this, maths is not my strong point
  11. Thanks for both your help guys only thing is I'm having a bit of trouble - I understand the code you guys posted and it works, but not in the way I intend it too. I'm given this example, which the program should do: 520 should factorize 2 × 2 × 2 × 5 × 13 Something like this I think : http://www.btinternet.com/~se16/js/factor.htm Thanks again
  12. Hi, I've currently written a prime test algorithm, and I want to extend it to factorise numbers into primes. For example, 55 factorises into 5 and 11. Here's part of the code I have so far for the prime testing - how would I extend this to factorise into primes? Thanks for ($check = 2; $check <= sqrt($num); $check++){ if ($num % $check == 0){ echo "This number is not prime. because $check is a factor! <a href=\"prime.php\">Try another number?</a>"; die(); } } echo "Number is prime! <a href=\"prime.php\">Try another number?</a>"; die();
  13. Ah ok thanks, the arrays should do fine
  14. Thanks only problem is in that scenario I'd have to make 25 arrays with the offsets for the different shifts - that's of course entirely possible and fine but just wondering if there's a more efficient way? Thanks
  15. Thanks for your reply. What a Caesar cipher does is increment every letter by a certain amount, so if by incrementing by two HELLO becomes JGNNQ
  16. Hi, I'm currently in the midst of coding some simple cryptography applications for my portfolio in University. I've decided to create a simple Caesar cipher encrypter/decrypter, and I'm struggling with the underlying code. Of course, I just want to get it working on a predefined string and shift before I add in code to let the user decide. The part I'm struggling with is converting each character in the string to it's ASCII value, then incrementing it. Can anyone offer any tips on how to do this? Here's my code so far: <?php $string = "Hello World"; $stringlength = strlen($string); for ($counter = 0; $counter < $stringlength; $counter++) { $string[$counter]++; echo $string[$counter]; } ?> Thanks
  17. Hi, my site is a resource for web designers featuring articles/tutorials and such. I've made a basic administration system where an article writer can write an article. On occasions the writer may need to write 'code' out, so I made a basic 'code' class, and used a preg_replace (which people on this forum helped me with) to change [ code] into <div class="code">..etc. Here is the code for this: $content = preg_replace('#\[code\](.*?)\[/code\]#ies', "'<div class=\"code\">'.htmlspecialchars('$1').'</div>'", $content); Only thing is I have two problems. As I'm using htmlspecialchars it doesn't pick up on REAL line breaks when an article writer wants to say, create a new line in the code DIV. One way of getting around this was using white-space: pre - however that caused more trouble, as text wouldn't wrap so long code would trail off the page to the right. I've been considering perhaps using the 'nl2br' function to convert line breaks to BR's, however how would I do this ONLY for text between the code tags? The $content variable contains all the articles content, so I assume I'll need to search that. Can anyone help? Thanks
  18. Ahh sorry, the query data is rather long as $content represents an article - so yeah there's a lot of quotes, thanks for the code to stop that The query data is created using a form, as the user can change the articles contents etc. The HTML code is: <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" > <b>Title (Title of the article):</b> <input name="authid" type="hidden" value="<?php echo $info['ID'];?>" /> <input size="60" maxlength="60" type="text" name="title" value ="<?php echo $title;?>" /> <br /><br /> <b>Short description of the tutorial:</b> <input size="60" maxlength="120" type="text" name="tutdesc" value="<?php echo $tutdesc;?>" /> <br /><br /> <b>Content:</b> <br /> <textarea name="content" rows="30" cols="80"> <?php echo $content; ?> </textarea> <br /><br /> <input type="submit" name="submit" value="Update Tutorial"/> I've tried each input box with different data, some including just text and no special characters such as quotes, and I've done the mysql_real_escape_string as you said: $title = mysql_real_escape_string($_POST['title']); $tutdesc = mysql_real_escape_string($_POST['tutdesc']); $content = mysql_real_escape_string($_POST['content']); Sorry if I've totally misread what you mean by post the $updatequery lol, thanks
  19. Ahh sorry I was just outputting the query to see if it was picking up the form details correctly. Using the code above I have an error: Here's the code for the entire update if (isset($_POST['submit'])) { $title = $_POST['title']; $tutdesc = $_POST['tutdesc']; $content = $_POST['content']; $updatequery="UPDATE tutorials SET title='$title', tutdesc='$tutdesc', content='$content' WHERE tutid=".$_GET['id']; $result = mysql_query($updatequery); echo ($result) ? 'Update successful. Rows affected (if any): ' . mysql_affected_rows() : 'Did not update. Error: ' . mysql_error(); Thanks
  20. Thanks for the reply - yeah I thought I had register_globals on, turns out I hadn't - so I converted the POST variables manually. But it still isn't updating the SQL table I've outputted the query value and it seems it does indeed contain the updated values, but for some reason these aren't updating the table :-?
  21. Hi, I am currently coding an 'Administrator' section of my website, which allows administrators to add articles to the site, edit ones they have created...etc. Currently I have this query which is for the Edit Article page, and this query happens when Submit is clicked of course: $updatequery="UPDATE tutorials SET title='$title', tutdesc='$tutdesc', content='$content' WHERE tutid=".$_GET['id']; mysql_query($updatequery); But the query doesn't actually update the table, and I have no idea why...is there any problems with the query? (Note I'm using PHP). I've made sure the variable names correspond with the HTML form names, but no joy yet - if it's any help my table features the following fields, in order: tutid, authid, catid, title, tutdesc, content, hits Thank you
  22. Thanks for both of your replies Ahh, didn't notice that DIV issue,thanks for pointing it out. And yeah lol I've mostly been experimenting with the front page at the moment, guess I got a bit happy with my DIV's I'm glad that you both think designing for 800 is old designing with a bigger width will give me much more freedom, I haven't created a website for a few years, so I haven't kept up with the trends - i'll be updating it tomorrow hopefully Just another quick question to anyone who would use such a site...what content would you like to see on such a site? Would you like to see more resources for Photoshop etc, more articles, or anything else? I'm not sure if I'm going off topic slightly, sorry if so!
  23. Thanks lots that's exactly what I wanted
  24. Please let me know what you think of this new website I am making http://www.designersvault.net (Sorry IE6 users, there seems to be a problem with rendering the page using IE6 at the moment, but I'm working on it)
  25. Hi, I am currently coding a system where I can have administrators of my website post up content that is posted onto the website - a lot of the time, it may be required to output HTML code as plain text, so using htmlspecialchars would be helpful. However, I want the administrators to also be able to use HTML, so I'm hoping I can do the following: [nobbc]When the user enters (code here) (like BBCode), it'll convert the 'code' tags to HTML DIV tags, so all the code can be in a DIV container which would be stylized using CSS. I have a very vague idea on how to accomplish this, using replace functions etc....but how would I make everything between the tags into a variable, so I can apply htmlspecialchars on it? Thanks [/nobbc]
×
×
  • 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.