Jump to content

se1zure

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

se1zure's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. If i am hosting this online, how woudl I go about doing this? Thanks. Oh, and the reason I'm interested is, I want to create a loops that I'll leave running for a few months on my other computer to find as high of a prime number as a can (and potentially break the current record). Of course, I will run this from that computer, and not the net... but not for now.
  2. I wrote a program where the user enters a number, and then it finds all the factors of that number, and displays it in a table. It works great for the most part. Up to numbers like 99,999,999, but then problems arise. Adding another 9 to that (which then runs the loop 900 million more times) gives me this error: Fatal error: Maximum execution time of 60 seconds exceeded in /home2/data/hosted/scetchbook/php/factor.php on line 10 Is there a way to turn off the execution time limit? I though that, since theoretically, it doesn't need to test every number past half of the original (because 2 is the second lowest factor you won't always have), so it only needs to run the loop half of the times. I will do this, but is there a way to turn off the execution time limit. Here is the code for the program: <?php // FactorFinder v1 $num = $_POST["num"]; ; $goto = 1; echo "<p align='center'>Factors of $num:</br >"; echo "<table width='600' cellpadding='2' cellspacing='2' bgcolor='white'>"; echo "<tr><td width='200' align='center' bgcolor='#B0E2FF'><b> Factor </td><td bgcolor='#8DB6CD' width='200' align='center'><b><font color='white'> Multiplyer </td><td width='200' align='center' bgcolor='#B0E2FF'><b> Resultant </td></tr>"; $prime = 0; while ($goto <= $num){ $fac = $num%$goto; if ($fac==0){ $mult = $num / $goto; echo "<tr><td width='200' align='center' bgcolor='#8DB6CD'> <font color='white'>$goto </td><td bgcolor='#B0E2FF' width='200' align='center'> $mult </td><td width='200' align='center' bgcolor='#8DB6CD'> <font color='white'>$num </td></tr>"; $prime = $prime + 1; } else { echo ""; } $goto = $goto + 1; } echo "</table>"; if ($prime==2){ echo "This is a prime Number. It is divisible by only 1 and itself.";} else { echo "This is not a prime number, there are a total of $prime factors.";} ?> Thanks
  3. Okay, I've got php to send emails, perfectly fine (for a contact me box I am making. here is, without all teh variables, the code: $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers = "From: $from"; mail($to,$subject,$message,$headers); echo "Mail Sent."; Using this method, the users inputted email adress shows up at the form in my inbox. but html DOES NOT work, and instead, the tags show up. So, for example, if this was the message they typed. Hello! I would like to affiliate! My Website url is: <a href="http://www.blah.com">http://www.blah.com</a> <font color="red">cool</font> then this is what i would see in the email in my inbox: -------------------------------- Hello! I would like to affiliate! My website url is: <a href="blah.com">website</a> <font color="red">cool</font> -------------------------------------------------- The email would be from [email protected]. So.. I rearranged the code like so: $headers = "From: $from"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail($to,$subject,$message,$headers); echo "Mail Sent."; Now, the email looks like this: ----------------------------------------------------- Hello! I would like to affiliate! My website url is: http://www.blah.com cool -------------------------------------------------- WHich is what I want, however, now the from email adress shows up as: [email protected] (which is my username and host), inb stead of [email protected] can you help me so i have both html supported emails, and the ability to set the from adrdes in the email.
  4. php is able to create databases, I thought?
  5. I decided to try out using mysql with php. I have mysl on my server, and I login, and create a new user. (the pic below shows the steps I follow). Using username = cory, and pw = 123456. [URL=http://allyoucanupload.webshots.com/v/2005256806995396933][IMG]http://aycu17.webshots.com/image/10136/2005256806995396933_rs.jpg[/img][/URL] [code] <?php $con = mysql_connect("localhost","se1zure_cory","123456"); if (!$con)   {   die('Could not connect: ' . mysql_error());   } // Create database if (mysql_query("CREATE DATABASE se1zure_postdata",$con))   {   echo "Database created";   } else   {   echo "Error creating database: " . mysql_error();   } // Create table in se1zure_postdata database mysql_select_db("se1zure_postdata", $con); $sql = "CREATE TABLE Person ( FirstName varchar(15), LastName varchar(15), Age int )"; mysql_query($sql,$con); mysql_close($con); ?>[/code] That is the code I am using to create a new database, and add a new table to it. THis is the error I get, can you tell me what i am doing wrong? [code]Error creating database: Access denied for user 'se1zure_cory'@'localhost' to database 'se1zure_postdata'[/code]
  6. bump,  can anyone help?
  7. I decided to try out using mysql with php. I have mysl on my server, and I login, and create a new user. (the pic below shows the steps I follow). Using username = cory, and pw = 123456. [URL=http://allyoucanupload.webshots.com/v/2005256806995396933][IMG]http://aycu17.webshots.com/image/10136/2005256806995396933_rs.jpg[/img][/URL] [code] <?php $con = mysql_connect("localhost","se1zure_cory","123456"); if (!$con)   {   die('Could not connect: ' . mysql_error());   } // Create database if (mysql_query("CREATE DATABASE se1zure_postdata",$con))   {   echo "Database created";   } else   {   echo "Error creating database: " . mysql_error();   } // Create table in se1zure_postdata database mysql_select_db("se1zure_postdata", $con); $sql = "CREATE TABLE Person ( FirstName varchar(15), LastName varchar(15), Age int )"; mysql_query($sql,$con); mysql_close($con); ?>[/code] That is the code I am using to create a new database, and add a new table to it. THis is the error I get, can you tell me what i am doing wrong? [code]Error creating database: Access denied for user 'se1zure_cory'@'localhost' to database 'se1zure_postdata'[/code] [attachment deleted by admin]
  8. I am new to php, and would liek to make a very dumbed down Content Management System, like cutenews (http://www.cutephp.com). I don't have any experience with mysql, nor a server which I can test out mysql on. What is the best way to go about creating this? What would you recommend I do, as far as file management? It should be simple (well, not too hard). I just want a list of all current stories, and a button to add a new story, delete an old story, and edit an existing one. Simple page to display them in order (depending on the date created). Shouldn't be too much of a hassel. SO if anyone knows of the best way of achiving this is, please feel free to help me out.
  9. you can use a sting modifier to convert all letters to lowercase, all to uppercase, or you can use an ignorecase. I'm not sure about using it in mysl, but I know that ther is something along the lines of: ingnore.case("") Not exact though.
  10. Alright. Well, right now, I just want it to add a click count to the thing, (and it sets a cookie, so that they can't just refresht he page). [code]<?php if (isset($_COOKIE["user"])){ // if it detects the cookie     echo "A hit is only added once per hour"; } // Tell me that it has detected the cookie. else if ($_GET[click] == "yes"){ // If no cookie is detected, and ?click is yes               setcookie("user", "VISIT", time()+3600); // Set a cookie               $filename= "counter.txt" ; // set filename var to counter.txt file.               $fd = fopen ($filename , "r") or die ("Can't open $filename") ; // open counter.txt in read only format.               $fstring = fread ($fd , filesize ($filename)) ; //Not %100 sure what this is for, just followed instructions.               echo "$fstring" ; // Print counter.txt               fclose($fd) ; // Close the connection with counter .txt               $fd = fopen ($filename , "w") or die ("Can't open $filename") ; // reopen counter.txt in write format               $fcounted = $fstring + 1 ; // Set $fcounted var to add one to $fstring.               $fout= fwrite ($fd , $fcounted ) ; // write to $fd connection the new number $fcounted               fclose($fd) } // close connection. else { // if neither of the if statments are met.     echo "<a href="?click=yes">Visit?</a>"; // display link to visit plage. }   ?> [/code] But this code outputs the error: [code]Parse error: syntax error, unexpected '}' in /home2/data/hosted/scetchbook/php/diggtest/story.php on line 15[/code] Which doesn't make sense... I am just closing the if else stament.
  11. HOw woult I go about keeping track of the number of times a link/submit button has been clicked? I want it to be very simple,a nd have the data be stored in a text file. I can't seemt o get the submit form to add 1 to the count without using a  second php page. (otherwise, simply refreshing the page adds one to the count) In other words, how can I make it so when I click a button (in a form), it runs a php script, but not until the button is clicked. ALl without leaving that page (refreshign is okay, but leaving the page is not).
  12. I am learning PHP, and I learn through programming, by solving problems. THe only downside to this, is that what I result with may be inefficient, and insecure. I use Digg.com alot, and was wandering, what would be the best method of making a "Digg this" style applicatoin, which will do the following (I know how to do most of this, but am not sure I am doing it efficiently, or the best way possible). -- I would liek to do this without the use of mysql, for now at least, as my knowledge of mysql is incredibly limited-- I will create a form, witha  submit button, to be attached to each story. There will be a $title variable which will be set to the name of the story. When the user clicks digg, it creates a txt file named the title of the story (unless it has already been made by the original digger), to keep track of it's diggs. It will cookie the user, and not allow them to digg it again. 9alothough, they can delete the cookie... oh well). I want then, to have the number of diggs displayed byt eh digg button. I realize to do updating inside the page, I would need to use ajax, correct? Anyways, Here is where I could also use help. I would liek to create a separate page, where any story with more than 10 diggs is displayed. i realize that with mysql, this would be fairly simple,  but is there anyway for a php script to read all the txt files in a folder, then get he name of the txt file, and extract the title of the story?
  13. The other day I decided that It would benefit me to learn PHP, because I already know html, css, and a bit of javascript. However, since PHP, is far more broad than html, and css (combined even), I think it has more potential. However, I am worried, that If I ever choose to write a utility in php, if I ever decided to sell it, how would I make the source closed? Being open source, basically ruins any chance of selling apps, (because basically, anyone can change a line of code, and claim it as their own). I realize I am probably stressign over nothing, but isnt' there a way to possibly encrypt the files or something, especially if I am using php with sensitive information (passwords etc).
  14. Well, I'm still new to php. I just started learning yesterday, but luckily I have a little java background. I havent gottento mysql databases yet (I am following an online Guide to PHP, and mysql comes up later). Here is what i am trying right now (I know, it's messy... Im a noob): [code] <?php $name = $_POST["name"]; // gets name from form $message = $_POST["message"]; // gets message form form if ($message == " " || $name == "" || $message == "")//detecs spam     $post = ""; else { // if the message and name are filled in, proceed. $filename= "counter.txt" ; // Get postcount text file $fd = fopen ($filename , "r") or die ("Can't open $filename") ; $fstring = fread ($fd , filesize ($filename)) ; echo "$fstring" ; fclose($fd) ; $fd = fopen ($filename , "w") or die ("Can't open $filename") ; $fcounted = $fstring + 1 ; $fout= fwrite ($fd , $fcounted ) ; //add to post count fclose($fd) ; if ($filename<=10){ // check if post count is < or = to 10 $post = "<b>$name:</b><br \> $message <hr NOSHADE>"; // declare post $myFile = "shouts.txt"; $fh = fopen($myFile, 'a+') or die("can't open file"); $stringData = "$post"; fwrite($fh, $stringData); // Post the entire message fclose($fh);   } else // If counter.txt HAS reached 10. {$myFile = "shouts.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = ""; fwrite($fh, $stringData); // Delete all current posts by writing w/ (w) fclose($fh); $fd = fopen ($filename , "w") or die ("Can't open $filename") ; $fcounted = $fstring = 1 ; $fout= fwrite ($fd , $fcounted ) ; // Reset counter to 1. fclose($fd) ; $myFile = "shouts.txt"; $fh = fopen($myFile, 'a+') or die("can't open file"); $stringData = "$post"; fwrite($fh, $stringData); // Post the entire message fclose($fh); } } ?>[/code] Right now, it adds to the counter.txt file, but for some reason, when it gets to ten, it doens't delete the posts, and restart the counter, it keeps counting, and adding to the posts. EDIT: Whoah! Anyone know if there is a program that color codes my java code , like the box above? I use eclipse for java, but I'm not usre if there is anyithing for php.
  15. Hi Everyone. I am making a simple PHP shout box, which writes to a text file. My problem is, that the text file can have unlimited posts, (it writes to it using the a+ method). My idea is to have a counter going, after each submitted posts, for example, create the var: $postcount = 0; and then, have each post use this: $postcount++; and : if ($postcount==10) { //CODE THAT WILL CLEAR THE TEXT FILE, then continue and post the new comment.} else // continue posting the comment. Basically, I need help with code that will clear a text file, and, if possible, backup that data to a continually running separate text file. Any help will be appriciated
×
×
  • 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.