Jump to content

ironman32

Members
  • Posts

    37
  • Joined

  • Last visited

    Never

Everything posted by ironman32

  1. What is a simple way to debug a script? Please bear in mind that I do not have access to my php.ini file.
  2. I'm using this piece of code as part of an array but I just needed to know what it is or its purpose. srand((float) microtime() * 10000000); I've read about it at php.net but I still don't fully understand. Would someone be able to break it down please?
  3. Ok, but before I start is it possible to get the contents of a web page, turn it into a variable and then send it to the database?
  4. Ok I've created the table 'php_session' in my database. How will I go about getting the page content to the table?
  5. I already have a database set up. So whats' next? I'll have to set up a table for the data right? Would something like this be along the right lines? CREATE TABLE `php_session` ( `session_id` varchar(32) NOT NULL default '', `id` varchar(16) default NULL, `date_created` datetime NOT NULL default '0000-00-00 00:00:00', `last_updated` datetime NOT NULL default '0000-00-00 00:00:00', `session_data` longtext, PRIMARY KEY (`session_id`), KEY `last_updated` (`last_updated`) ) ENGINE=MyISAM I borrowed this from a tutorial on saving session data.
  6. Ok, I already have a login system setup with usernames and passwords. The exercises for the workout are displayed in tables. Here's an example of this code <table border="1"> Session 1 <tr><td>Stretch/Warm up</td></tr> <tr><td><?php echo $input[$rand_keys[0]] . "\n";?></td></tr> <tr><td><?php echo $input1[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input2[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input3[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input4[$rand_keys[0]] . "\n";?></td></tr> </table> Now if I wanted to send this table and its data to the database, how would I go about doing it? The only time I have sent data to the database was with a form but I don't know how to do it with a table.
  7. The idea is that I have a page on a site which shows the user a workout schedule. I want the user save the schedule shown on this page so that they can look at it later. The page will be custom for the user.
  8. I'm trying to save the state of a web page so that a user can access it and view it when they need to at a later date. Can anyone give me some guidance on this please?
  9. I have had a reoccurrence of an if statement problem. This if statement does not work if the user selects the value "yes". if($_POST['medical'] = "yes"){ header("Location: acute.php?msg= Please consult your doctor before carring out these exercises"); die(); } I'm not sure why this is because it looks ok to me. Can anyone shed some light on this?
  10. I'm trying to align these tables in this format Session 1 Session 2 Session 3 Session 4 Here is the code for the tables Session 1 <table border="1"> <tr><td>Stretch/Warm up</td></tr> <tr><td><?php echo $input[$rand_keys[0]] . "\n";?></td></tr> <tr><td><?php echo $input1[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input2[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input3[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input4[$rand_keys[0]] . "\n";?></td></tr> </table> <p> Session 2 <table border="1" > <tr><td>Stretch/Warm up</td></tr> <tr><td><?php echo $input[$rand_keys[0]] . "\n";?></td></tr> <tr><td><?php echo $input1[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input2[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input3[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input4[$rand_keys[0]] . "\n";?></td></tr> </table> </p> Session 3 <table border="1" > <tr><td>Stretch/Warm up</td></tr> <tr><td><?php echo $input9[$rand_keys[0]] . "\n";?></td></tr> <tr><td><?php echo $input10[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input11[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input12[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input13[$rand_keys[0]] . "\n";?></td></tr> <tr><td><?php echo $input14[$rand_keys[0]] . "\n";?></td></tr> </table> Session 4 <table border="1" > <tr><td>Stretch/Warm up</td></tr> <tr><td><?php echo $input15[$rand_keys[0]] . "\n";?></td></tr> <tr><td><?php echo $input16[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input17[$rand_keys[1]] . "\n";?></td></tr> <tr><td><?php echo $input18[$rand_keys[1]] . "\n";?></td></tr> </table> Could anyone give me some guidance on this please?
  11. Can anyone give me some advice on how to save data from a php page to the database. The aim is for the user to save the state of the page they are on to view at a later date. I've looked a this tutorial by Tony Marston, http://www.tonymarston.net/php-mysql/session-handler.html, but it was a bit confusing. I've only managed to define a table in the database so far. Any help would be appreciated.
  12. I've added 'die' after each header if ($_POST['age'] == '' ){ header("Location: lose.php?msg= Please enter your age and weight"); die(); } if ($_POST['weight'] == '' ){ header("Location: lose.php?msg= Please enter your weight and age"); die(); } if($_POST['weight'] > 19){ header("Location: acute.php?msg= Please consult your doctor before carring out these exercises"); die(); } if($_POST['age'] > 60){ header("Location: acute.php?msg= Please consult your doctor before carring out these exercises"); die(); } if($_POST['medical'] = 'yes'){ header("Location: acute.php?msg= Please consult your doctor before carring out these exercises"); die(); } else{ header("Location: lose_weight.php"); die(); } ?> But I can't seem to redirect the user to lose_weight.php. Even if age < 60 , weight < 19 and medical ='no' , I still get redirected to acute.php.
  13. I've changed the code to protect the data and I eliminated the parenthesis <?php $con = mysql_connect("localhost","dontwork","123qwerty123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("db_name", $con); $age = mysql_real_escape_string($_POST['age']); $weight = mysql_real_escape_string($_POST['weight']); $medical = mysql_real_escape_string($_POST['medical']); if ($_POST['age'] == '' ){ header("Location: lose.php?msg= Please enter your age and weight"); } if ($_POST['weight'] == '' ){ header("Location: lose.php?msg= Please enter your weight and age"); } if($_POST['weight'] > 19){ header("Location: acute.php?msg= Please consult your doctor before carring out these exercises"); } if($_POST['age'] > 60){ header("Location: acute.php?msg= Please consult your doctor before carring out these exercises"); } if($_POST['medical'] == 'yes'){ header("Location: acute.php?msg= Please consult your doctor before carring out these exercises"); } else{ header("Location: lose_weight.php"); } ?> But only the last 'if' statement works. If the fields are blank the user still gets taken to lose_weight.php. I still need to get the other statements to work.
  14. Thanks but I still need to get these 'if' statements to work if(($_POST['weight']) > 19){ header("Location: acute.php?msg= Please consult your doctor before carring out these exercises"); } if(($_POST['age']) >60){ header("Location: acute.php?msg= Please consult your doctor before carring out these exercises"); }
  15. I've created some 'if' statements to process form data. <?php $age = $_POST['age']; $weight = $_POST['weight']; $medical = $_POST['medical']; if (empty ($_POST['age']) ){ header("Location: lose.php?msg= Please enter your age and weight"); } if (empty ($_POST['weight'])){ header("Location: lose.php?msg= Please enter your weight and age"); } if(($_POST['weight']) > 19){ header("Location: acute.php?msg= Please consult your doctor before carring out these exercises"); } if(($_POST['age']) >60){ header("Location: acute.php?msg= Please consult your doctor before carring out these exercises"); } if(($_POST['medical']) == yes){ header("Location: acute.php?msg= Please consult your doctor before carring out these exercises"); } else{ header("Location: lose_weight.php"); } ?> The idea is to redirect the user if 'weight' is over 19,their age is over 60 or if 'medical' = yes. Other wise they are redirected to a different page. The only 'if' statement that currently works is the 'medical' statement. Could somebody give me some advice on this please?
  16. Thanks DarkSuperHero. Problem solved.
  17. I have a series of links that I am using but intead of going to the link when its clicked, the link is added to my own url. for example The page I am on is http://www.phpfreaks/com. There is a link on this page to go to http://www.webhostfreaks.com. when I click on the link it gets added to the current url e.g. http://www.phpfreaks/com./http://www.webhostfreaks.com. How can I get the links to take me straight to the page? Here are the links I am using. $input = array("<a href= \http:www.muscleandstrength.com/exercises/seated-dumbbell-press.html/> Seated dumbell press</a>", "<a href= \http://www.muscleandstrength.com/exercises/seated-arnold-press.html\>Seated Arnold press</a>", "<a href=\http://www.muscleandstrength.com/exercises/standing-dumbbell-press.html\>Standing dumbell press</a>", "<a href=\http://www.muscleandstrength.com/exercises/standing-arnold-press.html\>Standing Arnold Press</a>"); Any help would be appreciated. Thank you
  18. I have a number of array lists that use the rand runction so that the elements come out at random. Here is my code <?php srand((float) microtime() * 10000000); $input = array("<a href= \http://www.muscleandstrength.com/exercises/good-mornings.html\ >Good mornings</a>", "<a href= \http://www.muscleandstrength.com/exercises/seated-good-mornings.html\>Seated good mornings</a>", "<a href= \http://www.muscleandstrength.com/exercises/deadlifts.html\> Deadlift</a>"); $rand_keys = array_rand($input); //echo $input[$rand_keys[1]] . "\n"; $input1 = array("<a href= \http://www.muscleandstrength.com/exercises/squat.html\>Squat</a>", "<a href= \http://www.muscleandstrength.com/exercises/dumbbell-squat.html\>Dumbell squat</a>", "<a href= \http://www.muscleandstrength.com/exercises/smith-machine-squat.html\>Smith Machine Squat</a>"); $rand_keys = array_rand($input1, 2); $input2 = array("<a href= \http://www.muscleandstrength.com/exercises/45-degree-leg-press.html\>45 degree leg press</a>", "<a href= \http://www.muscleandstrength.com/exercises/one-leg-45-degree-leg-press.html\>One leg 45 degree leg press</a>", "<a href= \http://www.muscleandstrength.com/exercises/dumbbell-lunge.html\>Dumbell lunge</a>"); $rand_keys = array_rand($input2, 2); $input3 = array("<a href= \http://www.muscleandstrength.com/exercises/seated-calf-raise.html\>Seated calf raise</a>", "<a href= \http://www.muscleandstrength.com/exercises/45-degress-calf-press.html\>45 degree toe raise</a>", "<a href= \http://www.muscleandstrength.com/exercises/seated-dumbbell-calf-raise.html>Seated dumbell calf raise</a>"); $rand_keys = array_rand($input3, 2); ?> What I am trying to do is output an element from each array into an ordered list e.g. 1.Good mornings 2.Squat 3.45 degree leg press Can anyone offer any help on this?
  19. What I'm trying to do is show an error message if a field is empty. Here is my code <?php $age = $_POST['age']; $weight = $_POST['weight']; $medical = $_POST['medical']; if (empty ($_POST['age']) ){ header("Location: lose.php?msg=Invalid Login"); } ?> I'm currently getting this error message Warning: Cannot modify header information - headers already sent by (output started at /home/dontwork/public_html/workout3/lose2.php:2) in /home/dontwork/public_html/workout3/lose2.php on line 9 If anyone can help I would appreciate it.
  20. I've been using the array_rand function based on this example <?php srand((float) microtime() * 10000000); $input = array("Neo", "Morpheus", "Trinity", "Cypher", "Tank"); $rand_keys = array_rand($input, 2); echo $input[$rand_keys[0]] . "\n"; echo $input[$rand_keys[1]] . "\n"; ?> I just wanted to know what this part of the code meant $input[$rand_keys[0]] .; Would anyone be able to explain it to me please?
  21. I tried to put a html link within a php function <?php function lfc(){ echo "<a href="www.lfc.tv">LFC</a>"; } echo lfc(); ?> This hasn't worked so I'm wondering if its possible. Any help would be welcomed
  22. I've tried it out and you're right it does exactly what I needed. Thanks everyone for all the help
  23. What I am aiming to do is to have a full list within an array e.g. $input1 = array(<ol><li><a href =\"http://www.muscleandstrength.com/exercises/barbell-bench-press.html\">Bench press</a></li> <li><a href =\"http://www.muscleandstrength.com/exercises/military-press-behind-neck.html\">Military Press behind the neck</a></li> <li><a href=\"http://www.liverpoolfc.tv\">A</a>","<a href =\"http://www.muscleandstrength.com/exercises/military-press-behind-neck.html\">C</a>"</li> <li>"<a href =\"http://www.muscleandstrength.com/exercises/military-press-behind-neck.html\">B</a></li></ol>") So it can produce an output like this 1.Bench press 2.Military press behind the neck 3.C 4.B Is that more understandable?
×
×
  • 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.