Jump to content

Bentley4

Members
  • Posts

    58
  • Joined

  • Last visited

    Never

Everything posted by Bentley4

  1. Where exactly do I add the parameter in the query string for this code? The text I want is in row two.
  2. Hi guys, How do I call the 2nd row of 'TSuperQuestion'? <?PHP $con = mysql_connect("localhost","ph6theo", "xxxx"); if (!$con) { die('Could not connect: ' . mysql_error("oop")); } mysql_select_db("ph6theo_testDB") or die(mysql_error()); $result = mysql_query("SELECT * FROM QANDATable "); $row = mysql_fetch_array($result); echo $row['TSuperQuestion']; ?>
  3. Changed it and it works. Thnx PFMaBiSmAd!
  4. Hi guys! I inputted text into the field 'TSuperQuestion' of my table. Now I am trying to echo that text. I get the following error: This is my code: <?PHP $con = mysql_connect("localhost","ph6theo", "xxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("ph6theo_testDB") or die(mysql_error()); $result = mysql_query("SELECT * FROM Q&ATable"); $row = mysql_fetch_array($result); echo $row['TSuperQuestion']; ?> Can anyone help?
  5. Hi guys! I've just created a table in mysql as follows: id int(100) TStudentNumber int(9) SignInDate datetime TSuperQuestion text TQuestion text TAnswer text SignOutDate datetime But when I go to insert in phpmyadmin and write a sentence in the value field of Tquestion I get this error: 1 row(s) inserted. Inserted row id: 5 Warning: #1366 Incorrect integer value: '' for column 'TStudentNumber' at row 1 Warning: #1264 Out of range value adjusted for column 'SignInDate' at row 1 Warning: #1264 Out of range value adjusted for column 'SignOutDate' at row 1 Any idea why?
  6. But php is interactive as well, no? Is there anything in js that you couldn't actually write in php?
  7. Hi everyone, I understand that Js is clientside and php is serverside. But why would anyone want to do clientside programming when you can do serverside programming? Could you give some examples from sites and say what is better to do in javascript and what is better to do in php?
  8. Can anyone see what is wrong with this code? I get the following parse error: syntax error, unexpected $end if(isSet($_GET['answer'])) { $answ = $_GET['answer']; $nextanswer=$answ+1;} else{} $counter2 = 1; while ($counter2 <= $answ): echo $Answer[$counter2]."<br>"; $counter2++; endwhile; if($nextansw>0){ if(isset($Answer[$nextanswer])){ echo "<a href=\"/Code-sandbox.php?sid=".$name."&answer=".$nextanswer."\">next</a>";} else{echo "End of questions<br>";} else{}
  9. In the following code the sign "\" is used before "/index.php?....". What does this sign mean in a link statement? Does it mean it automatically adds the url of the webfolder or phpfile? <?php echo "<a href=\"/index.php?sid=".$name."&question=".$nextquest."\">next</a>"; ?>
  10. I don't understand why "if(isSet($_GET['sid'])) " works before it is declared in the variable name(" $name = $_GET['sid'];"). 1. How does php store the date in this get statement? 2. Is GET an array? if(isSet($_GET['sid'])) { echo "<h2>Exercise</h2>"; $name = $_GET['sid']; $timein = time(); $quest=1; $nextquest=2; } else { echo "<h2>Enter Student Number:</h2>"; $quest=0; $nextquest=0; }
  11. K, Thnx for the advice Paulryan. I fiddled around with it and adjusted it. New problem(something I can't easily figure out myself): After the data is submitted,you would see again a form(with a question). (And the same code again with adjusted content) I would like to implement at least 10 questions like this. Problem: I would have to nest each code of the page into the echo statement again. It becomes unreadable! Isn't there another way to have the same funtionality without nesting? I'm thinking something with a counter, but I have no idea where to start. What do you think?
  12. Hey Paulryan, Thnx! No parsing errors and it sends the data to the textfile! But there is still something wrong: The first else statement can't be triggered! When I don't fill in anything and click submit, it doesn't work different then filling in something and clicking on submit. I don't get the notice "Form not posted." Also, where should I put: echo 'Long Content Here.';
  13. Thanks Paulryan!! I've first tried to adjust the code that I was working on and posted the bit before the echo statement and it doesnt give any parsing errors. Thanks for that. You were right, this code doesn't show any submit field and button. I've tried your code, it doesnt give any parsing errors, it also shows the submit button and field but when I fill in something and click submit it doesn't send this data to the textfile anymore. Any idea why?
  14. @Wildteen88 Thanks, this works!! But actually my code is still a bit longer, I left a bit out for the sake of brevity. When I include this bit it still gives an error though. Can anyone see why? The extra code is written in bold(without the code written in bold it works iow) <?php if ($_GET=='') echo '<form name="input" action="http://www.xxx.uk/index.php?name=ro" method="post"> Enter student number:<input type="text" name="sid"/> <input type="submit" value="Submit"> //Why is the following between the php tags giving an error? <?php $name = $_POST['sid']; $timein = time(); $fp = fopen("formdata.txt", "a"); $savestring = $name . "," . $timein . "\n"; fwrite($fp, $savestring); fclose($fp); ?> </form>;' else if ($_GET=='ro') echo "the really long content that you want in here"; ?> @PaulRyan I first want this thing to work and then I'll get to your comment Thanks in advance : )
  15. Thnx violinrocker! But when I use this code I get a parse error. The code: <?php if ($_GET=='') echo{ <form name="input" action="http://www.xxx.uk/index.php?name=ro" method="post"> Enter student number:<input type="text" name="sid"/> <input type="submit" value="Submit">" </form>;} else if ($_GET=='ro') echo {"the really long content that you want in here";} ?> I can't find where the syntax error is, can anybody see where?
  16. Hi guys! How do I display different code depending on the title/url? This is the code for the form that brings you from "http://www.xxx.uk/index.php" to "http://www.xxx.uk/index.php?name=ro": <form name="input" action="http://www.xxx.uk/index.php?name=ro" method="post"> Enter student number:<input type="text" name="sid"/> <input type="submit" value="Submit"> Now when you are on "http://www.xxx.uk/index.php?name=ro" I would like another content(but written in the same php file). I tried with _GET, but the problem is that I don't simply want to add a word but a lot of content. With _GET, that whole content would have to be displayed in the title and I don't want that.
  17. Wow, nice one cyberRobot! Impressed that you spotted that. Thank you, it works!
  18. No, the problem isn't solved! I did everything according to that tutorial: http://www.howtoplaza.com/save-web-form-data-text-file 1. I Implemented that first piece of code in my main webpage php file. 2. Made a "formdata.txt" file, inputted 'Name,Mail,[enter]' and saved it in my webfolder. 3. Then made a “process-form-data.php” in my webfolder and inserted this code: <?php $name = $_POST['name']; $email = $_POST['email']; $fp = fopen(”formdata.txt”, “a”); [color=blue]$savestring = $name . “,” . $email . “n”;[/color] fwrite($fp, $savestring); fclose($fp); [color=blue]echo “<h1>You data has been saved in a text file!</h1>”;[/color] ?> When I check the webpage of “process-form-data.php” it says Why? I don't see any concatenation errors in line 7 nor any mistakes in line 10
  19. Thank you for your response guilty gear. I just found a blog that claims it is possible and explains how to save web form data through using this php code: <?php $name = $_POST['name']; $email = $_POST['email']; $fp = fopen(”formdata.txt”, “a”); $savestring = $name . “,” . $email . “n”; fwrite($fp, $savestring); fclose($fp); echo “<h1>You data has been saved in a text file!</h1>”; ?> From tutorial: http://www.howtoplaza.com/save-web-form-data-text-file 1. Why does the the person who wrote the tutorial save this php code into a seperate php file? 2. When I use this code in my php file of my webpage I get this error: And it refers to this line: $savestring = $name . “,” . $email . “n”; Why?
  20. Hello! I'd like to know how one can save inputted data using a form to store it into another php file. The user should just input their name in the php webpage called "MainPage.php". When they write their names and hit submit, they would just stay on the same page. Their submitted names should be stored permanently into a "Answers.php" file. What do I need to change in my "MainPage.php code? <html> <body> <form method="post" action="Answers.php" > Name:<input type="text" name="Name" /> <input type="submit" value="Submit name" /> </form> [some php code not relevant to question] </body> </html>
×
×
  • 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.