Jump to content

Genesis730

Members
  • Posts

    96
  • Joined

  • Last visited

Everything posted by Genesis730

  1. The best way is to make stuff, do a forum or make a program, something to keep challenging your skills, maybe learn better and more efficient ways to code
  2. It's giving you an error for anytime you use a variable that hasn't been inialized yet. To stop that, just post this BEFORE the error (I.E. the variables are used) <?php error_reporting(E_ALL ^ E_NOTICE); ?>
  3. So is there any way I can change multiple rows at once?
  4. $datestring = "Apr 1 2011"; $new_date = date("m-d-Y", strtotime($datestring)); if you echo $new_date, it will show up 04-01-2011
  5. I'm trying to update every record where one field in a row is less than the other. The code gets each row i'm looking for and sets up the query right, I hope I combined the entire query into one string each query seperated by a ; so it's like UPDATE `table` SET field2= '1' WHERE field1= '1';UPDATE `table` SET field2= '1' WHERE field1= '2';UPDATE `table` SET field2= '1' WHERE field1= '3';UPDATE `table` SET field2= '1' WHERE field1= '4';UPDATE `table` SET field2= '1' WHERE field1= '5'; this executes properly if i run the query in phpMyAdmin, however when I run the query in PHP, it does nothing... Any advice?
  6. Yes, you can do an if statement for each case if ($result['group'] == 1) { echo 'Group 1'; } elseif ($result['group'] == 2) { echo 'Group 2'; } else { echo 'Group 3'; or do a switch (much easier if you have multiple groups and it looks nicer switch ($result['group']) { case "1": echo "Group 1"; break; case "2": echo "Group 2"; break; case "3": echo "Group 3"; break; default: echo "Error, Group does not exist; break; }
  7. The session is called everytime a webpage is called, it's part of session.php which is included at the top of each page. That is the only code that references generateRandID other than updating it to the database. And if forming a construct by naming a method the same as the class has been deprecated since php 5, what would be an example of how properly code what i am attempting?
  8. So I have this code that generates a random ID class Session { var $username; //Username given on sign-up var $userid; //Random value generated on current login ... ... function Session(){ $this->time = time(); $this->startSession(); } ... ... $this->userid = $_SESSION['userid'] = $this->generateRandID(); ... ... function generateRandID(){ return md5($this->generateRandStr(16)); } and when it runs i get this error... Fatal error: Call to undefined method Session::generateRandID() Any ideas?
  9. I'm no expert but don't you need to escape the quotes so the echo doesn't end before you want it to? Also you're trying to target your link to a PHP value, but the code isn't in PHP, at least from the code provided, if that's the case you would need the link to be like this <a href="<?PHP echo get_permalink($id); ?>"> <?PHP echo get_the_title($id) . '</a></li>';?> The whole thing would look something like this, let me know how it goes... <?PHP echo "<li><?php dp_attachment_image($post->ID, \'thumbnail\', \'alt=\'" . $post->post_title . "\' class=\"footer-thumb\" width=\"40px\" height=\"40px\""); ?><a href="<?PHP echo get_permalink($id); ?>"> <?PHP echo get_the_title($id) . '</a></li>'; ?>
  10. So I'm having fun designing this site to create leagues and I have the site functional as far as creating a new league and setting up it's own site with members, etc. However I'm having trouble even planning how to setup the database to manage leagues, rankings, creating tournaments, etc. I know it's hard to help without code or anything to start with but like I said I can't even begin to put something functional together in my head. With that in mind, i'd really appreciate ANY input or advice anyone can give. Thanks in advance for anything anyone can provide.
  11. I have it on a WAMP server, so IDK if there's default permissions set on that, if so how would I turn them off and if not, any other ideas??
  12. So I think I'm close, now I get a permission error, specifically " [function.fopen]: failed to open stream: Permission denied" here's the code... $fsrc = fopen($tempdir,'r'); $fdest = fopen($leaguedir,'w+'); $len = stream_copy_to_stream($tempdir,$leaguedir); fclose($fsrc); fclose($fdest); return $len; Any ideas?
  13. Please click the green button located on the bottom left which says "MARK SOLVED" when you have your answer Thank you
  14. It appears, with the script on http://us2.php.net/copy by nensa at zeec dot biz as if the script is trying to look for the initial and final directory where the script is located. Here is the error Warning: fopen(*WAMP Dir*/temp/) [function.fopen]: failed to open stream: No such file or directory in *WAMP Dir*/process.php on line 141, line 141 is the start of the script "$fsrc = fopen($tempdir,'r');" Any ideas?
  15. How can I transfer files from one directory to another?? Here's my code, however I get this error... "The second argument to copy() function cannot be a directory in *WAMP Dir*/process.php on line 141" Line 141 is - copy($tempdir, $leaguedir); $tempdir = $_SERVER['DOCUMENT_ROOT']."temp/index.php"; $enddir = $_SERVER['DOCUMENT_ROOT'].$dir; copy($tempdir, $enddir); I planned on doing this several times, one for each file, however if anyone knows how to do the entire directory, that would be awesome!
  16. Yeah, if they're not logged in, go to index.php, else create the directory, then if there's an error with the directory, echo there was an error processing the request.
  17. I hope someone can find an error with this. I keep getting "Parse error: parse error in process.php on line 145" 131 function procCreate(){ 132 global $session, $form; 133 if($session->logged_in){ 134 $dir = preg_replace("/(.*)(\/)$/","\\1", $dir); 135 $dir = $session->username; 136 $absolute_dir = $_SERVER['DOCUMENT_ROOT'].''.$dir; 137 if (!is_dir($absolute_dir)) { 138 mkdir($absolute_dir, 0777); 139 chmod($absolute_dir, 0777); 140 return $absolute_dir; 141 } 142 else { 143 echo "There was an error processing your request"; 144 } 145 else { 146 header("Location: index.php"); 147 } 148 } 149 }
  18. i suppose something like this would do the trick, huh?? haha im an idiot sometimes. include("inputform.php");
  19. Take a look at this function, call it after the execution of each mysql_query command and create a running total
  20. I have my page setup something like this... <?PHP if($loggedin){ echo "Welcome <b>$username</b>, you are logged in. <br><br>"; } else{ $content = file_get_contents("loginform.php"); echo $content; } ?> i did this workaround because the login form displays "Username" and "password" if the initial value is null and without echoing the form as different page, the PHP has a lot of errors, code for the input looks something like this. value="<?PHP if ($form->value("user")=="") echo "Username"; else echo $form->value("user"); ?>"> my question is can anybody advise a better way to approach this or fix the error because as it stands everything works except the echoed page displays the php code instead of executing it on the server.
  21. <html> <head> <title>()</title> </head> <body> <?php if($_POST['Submit']) { //COLLECT DATA $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $message = $_POST['message']; //EMAIL $emailName = "TEST"; $emailFrom = "Email From: " . $name; $emailSubject = $name . " - " . "SUBJECT"; $emailMessage .= "\nMessage from: " . $name; $emailMessage .= "\nEmail Address: " . $email; $emailMessage .= "\nPhone Number: " . $phone; $emailMessage .= "\n\nMessage: " . $message; //ERROR CHECKING $error = ''; if (!$name) $error = $error."<b>Name</b> "; if (!$email) $error = $error."<b>Email Address</b> "; if (!$phone) $error = $error."<b>Phone Number</b> "; if (!$message) $error = $error."<b>Message</b> "; if ($error!="") echo "<span id='red'><font size='4'>Please fill out all required fields</font><br />$error</span>"; else { //SUBMIT & REDIRECT mail( "email@yahoo.com", "Subject: $emailSubject", $emailMessage, "From: $Email" ); echo ("Thanks!"); } } ?> <form method="POST" action="form.php"> <table> <tr> <td>Name:</td> <td><input size="25" name="name" value="<?PHP echo $_POST['name']; ?>"></td> <td>Email:</td> <td><input size="25" name="email" value="<?PHP echo $_POST['email']; ?>"></td> <td>Phone Number:</td> <td><input size="25" name="phone" value="<?PHP echo $_POST['phone']; ?>"></td> </tr> <tr> <td>Message:</td> <td><textarea size="25" name="message" value="<?PHP echo $_POST['message']; ?>"></td> </tr> </table> <input type="submit" name="submit" value="Submit" /> </form> </body> </html>
  22. Try escaping the +?? Just a thought
×
×
  • 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.