Jump to content

jcbones

Staff Alumni
  • Posts

    2,653
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by jcbones

  1. session_register I wouldn't do that. 1. You already have the POST data in your SESSION array, as is evident with that print_r. 2. This is because you already have called session_start(); So, now you need to make sure you have session_start at the top of EACH page that you want to use these variables. They will reside inside the same variables as long as the session is started. I can help you, but I need the form flow. As in the start of the order, flowing to the end of the order. Otherwise, I could just give you snippets all day without ever getting it to work right.
  2. Run some de-bugging, at the top of the page put this> change print_r ($_REQUEST) ; To echo '<pre>' . print_r($_SESSION,true) . '</pre>'; Then post the script with the output.
  3. ??? How does an echo mess up a theme? An echo writes data to a browser, if it messes up a theme, it is because PHP has been told to send the wrong data to the browser.
  4. There should be no reason to keep duplicate data in a table, it will just eat up resources needlessly. Coding the other two would just be deciding on a duplicate update, or just suppressing an error.
  5. <?php $date_compare = new DateTime('2011-12-17T12:00:06+0000'); //start a date time object with the time to compare. $current = new DateTime(); //and a date time object of the current time. $difference = $date_compare->diff($current); //get the difference //difference now holds an object with all of the information. echo <<<EOF <pre> Years: {$difference->y} Months: {$difference->m} Days: {$difference->d} Hours: {$difference->h} Minutes: {$difference->i} Seconds: {$difference->s} </pre> EOF; ?>
  6. I'll let you do the other one. <?php session_start(); //start session; $_SESSION['post_data'] = $_POST; //store all post data to the session array. print_r ($_REQUEST) ; /*if(isset($_POST['ORDER'])) { $ORDER = $_POST['ORDER']; } if(isset($_POST['PTYPE'])) { $PTYPE = $_POST['PTYPE']; } if(isset($_POST['DTYPE'])) { $DTYPE = $_POST['DTYPE']; } if(isset($_POST['PSIZE'])) { $PSIZE = $_POST['PSIZE']; } if(isset($_POST['DSIZE'])) { $DSIZE = $_POST['DSIZE']; } if(isset($_POST['PTYPE2'])) { $PTYPE2 = $_POST['PTYPE2']; } if(isset($_POST['DTYPE2'])) { $DTYPE2 = $_POST['DTYPE2']; } if(isset($_POST['PSIZE2'])) { $PSIZE2 = $_POST['PSIZE2']; } if(isset($_POST['DSIZE2'])) { $DSIZE2 = $_POST['DSIZE2']; } if(isset($_POST['PTYPE3'])) { $PTYPE3 = $_POST['PTYPE3']; } if(isset($_POST['DTYPE3'])) { $DTYPE3 = $_POST['DTYPE3']; } if(isset($_POST['PSIZE3'])) { $PSIZE3 = $_POST['PSIZE3']; } if(isset($_POST['DSIZE3'])) { $DSIZE3 = $_POST['DSIZE3']; } */ echo "Order Type: <br/> \n"; echo"<form method='post' action='project2.php'>"; //set the variables. $DEL = NULL; $TAKE = NULL; $EAT = NULL; if(isset($_SESSION['post_data']['ORDER'])){ if ($_SESSION['post_data']['ORDER'] == 'delivery') { $DEL='selected' ; }elseif ($_SESSION['post_data']['ORDER'] == 'takeout') { $TAKE='selected' ; }elseif ($_SESSION['post_data']['ORDER'] =='eatin') { $EAT='selected' ; } } echo"Delivery <input type='radio' name='ORDER' value='delivery' $DEL>" ; if(isset($DEL)){ echo $DEL; } echo"Take Out <input type='radio' name='ORDER' value='takeout' $TAKE>" ; if(isset($TAKE)){ echo $TAKE; } echo"Eat in <input type='radio' name='ORDER' value='eatin' $EAT>" ; if(isset($EAT)){ echo $EAT; } //set the variables. $NOPIZZA = NULL; $CHEESE = NULL; $PEPPORONI = NULL; $VEGGIE = NULL; $MEAT = NULL; if(isset($_SESSION['post_data']['PTYPE'])){ if ($_SESSION['post_data']['PTYPE'] == 'no pizza') { $NOPIZZA='selected' ; }elseif ($_SESSION['post_data']['PTYPE'] == 'cheese') { $CHEESE='selected' ; }elseif ($_SESSION['post_data']['PTYPE'] =='pepporoni') { $PEPPORONI='selected' ; }elseif ($_SESSION['post_data']['PTYPE']=='veggie') { $VEGGIE='selected' ; }elseif ($_SESSION['post_data']['PTYPE'] =='meat lovers') { $MEAT='selected' ; } }
  7. You will have to use the mysql functions and not mysqli, as you cannot mix the two. <?php $db = new Database(); $q = "SELECT post_id, post_title, post_subtitle, post_body, DATE_FORMAT(post_created, '%M %D %Y') AS created_on, post_ext_link FROM blog ORDER BY post_id DESC LIMIT 3"; $r = $db->query($q); if (mysql_num_rows($r) > 0) { while ($row = mysql_fetch_assoc($r)) { echo "<h2>" . $row['post_title'] . "</h2>" . "<h3" . $row['post_subtitle'] . "</h3>" . "<p" . $row['post_body'] . "</p>" . "<p" . $row['created_on'] . "</p>" ; } } else { echo '<p>No posts to display at present.</p>'; } ?>
  8. Are you using a browser that has development tools (ie Firefox)? If so, open up tools->web developer->error console, clear it, then run the script and post up the errors that it throws.
  9. I'm sure they are also, but I am also as sure that they can point out the problem much faster than ourselves. Being that A: They know their system, and B: They will get you up and running much faster so they can get some of your money.
  10. Contact PayPal
  11. Sorry, been gone a few days. You need to add the region to your url. echo "<a href=\"?page={$i}&region={$region}\">{$i}</a> ";
  12. Short tags is a lazy way of opening a PHP file (<? instead of <?php). While short tags are enabled on a lot of servers, it is not enabled on ALL, so it may fail if moved to a different server. Prior to 5.4.0 this included the short form of echo <?=, but after 5.4.0 that will work even if short tags is turned off.
  13. Off the top of my head, I would make sure that those files did not use short tags.
  14. What does this line return? echo "<p>Number of models found: ".$TOTALROWS."</p>"; Also, have you echo'd out your queries and run them straight in the database console (or software)?
  15. I'll second Ryans suggestion, but be aware DOMDocument can be tedious at times. Perhaps you could contact the site admin, and see if they have an API available for this type of project. Most game servers do, and would make it much easier (and it won't break when site design changes).
  16. AJAX which is Javascript. AJAX calls to the server for a file, which can be PHP. PHP file queries the database, output is returned to the AJAX call. Some great tutorials here. I'd recommend any of the first 3.
  17. You need to make sure $task_value has the desired contents (echo it). You should have only 1 task per row, and perhaps a separate table for task, and a separate table for task_completed. My take: Tables CREATE TABLE `user` ( id int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL, username varchar(20) NOT NULL, `password` varchar(41) NOT NULL, PRIMARY KEY (id) ) CREATE TABLE `task` ( id int(11) NOT NULL AUTO_INCREMENT, task_name varchar(20) NOT NULL, task_class int(3) NOT NULL, task_level int(3) NOT NULL, PRIMARY KEY (id) ) CREATE TABLE `task_complete` ( `user_id` INT( 11 ) NOT NULL , `task_id` INT( 11 ) NOT NULL ) Now you can insert your task in their own table, totally separate of the users, this being much more efficient, in that you do not have to update 500 rows to add 1 task. Simply by adding 1 task your users can immediately complete them. Adding a user INSERT INTO user (username,password) VALUES ('Big Bald Head',PASSWORD('IamAmonkey')); Adding task INSERT INTO task(task_name,task_class,task_level) VALUES('Find a Woman',5,100); Now that you have a task, all users can now see it with a simple call to: SELECT task_name FROM task ORDER BY id DESC; If they complete it, you insert a row into task_complete. INSERT INTO task_complete (user_id,task_id) VALUES (1,1); To see how many task a user has completed, you just call the task completed table joined with the user and task tables. SELECT u.username, t.task_name FROM task_complete AS c JOIN user AS u ON u.id = c.user_id JOIN task AS t ON t.id = c.task_id If you need to limit it to a single user, just add the where clause SELECT u.username, t.task_name FROM task_complete AS c JOIN user AS u ON u.id = c.user_id JOIN task AS t ON t.id = c.task_id WHERE c.user_id = 1 This Post is to help you get your database . Which will turn changes to your project from a headache, to a breeze.
  18. Lets work through this route from a basic standpoint. 1. Place this file in your ROOT directory. .htaccess Options +FollowSymlinks RewriteEngine on RewriteRule ^(.*).htm$ testmodwrite.php 2. Place this file in your root directory: testmodwrite.php <?php echo '<h1>Mod re-write has just sent you to this PHP file from a htm request!</h1>'; ?> 3. If this works, then you can slowly add rules until it works as desired. Mod re-write can be confusing to some trying to learn it. 4. For further help you can set the RewriteLogLevel to 3 or higher (de-bugging only), and make sure you can view the RewriteLog file. Manual to Mod rewrite
  19. Yes, and that is how your server is seeing it, but that isn't a valid filepath. You must point your mod-rewrite to a valid file path. Maybe something like: RewriteEngine on RewriteRule ^/route/([A-Za-z0-9]+)$ index.php?route=$1 [PT] This is assuming that your .htaccess file resides in the testsite directory, and you want it to open the index file.
  20. You never overwrite their password before getting confirmation from their email, otherwise someone could spam your forgotten password form with random emails and lock out every user you have (until they check their email). For the links, you need to look at the _GET array HERE. For the tokens, you could create a function to generate a random string of characters, coupled with the current time: Example Only <?php function randomToken() { $str = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789'; //random string of letters and numbers. $token = NULL; //set the variable. for($i=0;$i<50;$i++) { //loop 50 times. $token .= $str[mt_rand(0,(strlen($str)-1))]; //add a random letter from the string to our token variable. } return sha1($token) . time(); //hash the result, then add the time to the end of it. } ?> NOTE: Do not use md5, sha1, sha256 for password storage, even the manual suggests against that. read about it
  21. On a development server, error-reporting should be set to -1 IMHO. This way it will include any future levels or constants add to error_reporting. 32767 is E_ALL in PHP 5.4 (which combined E_STRICT and E_ALL).
  22. <?php foreach($item as $key => $value) { if($key == 'Today') { continue; //move to next item key. } echo $key . '=' . $value . "<br />\n"; } Continue.
  23. Yes, there is. Specify an absolute file path. Includes will always read according to the called script. So, if you have scriptA in folderA that includes a file in folderB, that includes another file from folderB. PHP will not find this file if it is passed a relative file path, because PHP will be looking in the directory that scriptA is residing in (folderA). To get passed this, you must specify an ABSOLUTE FILE PATH. include(dirname(__FILE__) . '/myincludedfile.php'); //will include a file in the same directory as the current file. include(dirname(__FILE__) . '/folderB/myincludedfile.php'); //will look on folder down for the file.
  24. Yes, you learn the framework (which will be PHP based), some vary slightly from PHP basics, others vary a whole lot. A bad thing? I don't think so, but I do think that you should have a very good working knowledge of PHP before branching off into frameworks. This would help you in the long run. Not all frameworks have a template system, or some that call them templates mis-use the term. With a large user base I would suggest a framework. This will allow your developers to work within a set confine of rules. This will lead to better code consistency, and ease of migration from one developer to the next. The reason I suggest frameworks: 1. The major part of it is written which saves 1,000's of hours on a project like this. 2. The good frameworks are consistently running security checks on their products. 3. Future development of your project will follow the same rules as the current development.
  25. $goldprice most likely doesn't hold what you think it does.
×
×
  • 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.