Jump to content

ifis

Members
  • Posts

    60
  • Joined

  • Last visited

    Never

Everything posted by ifis

  1. I am trying to set up a simple blog. I have a textarea where people can input their thoughts, but when I process the input through the programming it all of the spacing, most importantly the paragraph spacing is removed. I want to be able to find areas in the text where there are multiple spaces and then replace those with a </p><p>. $correctarticle=preg_replace(' ++',</p><p>,$_POST['Article']); this is not working. Any ideas? Thanks
  2. Basically, I took a document I had in word, then cut and pasted it into Dreamweaver and cleaned it up. I then took the html from Dreamweaver and put that into the field in my database. I have that field set up as 'text' and 'utf8_general_ci'. I don't know if that makes any difference, I usally use VARCHAR instead of TEXT in mysql databases.
  3. I think it is a double space problem. I notice if I manually delete the two spaces between characters it gets rid of the square. I am perplexed with why the squares show up, because if I look at the HTML of the posted page it does not include them. I guess my question is; how could I trim the extra spaces? I'm assuming I need some kind of replace function. I'm not sure how I can find 2 consecutive blanks then delete one of them though. Any ideas? I cut and past the data in the table from a HTML file, I'm going to try if I input the data through a form if it will have the same problem. My code is: $sql = "SELECT * FROM blog WHERE LoginName='$row[loginName]'" or die("cannot connect to table"); $result=mysql_query($sql); while($row = mysql_fetch_array($result)){ echo "<h1>$row[Title]</h1>"; echo "<p align='right'>Submitted: $row[Date]</p>"; echo "$row[Article]"; Thanks
  4. I have a simple query to a database that is supposed to post articles that people have submitted, the only problem is that there is a square after each period. (i.e. "drag?�� The student responded, �Induced drag increases when flaps are extended.�� This is not correct.� Induced") I have the field set to text. What am I doing wrong and how can I fix it? Thanks.
  5. This is a little off topic, but I just check the last post while working. If I use radio buttons or a drop down menu, do I need additional form validating as long as I am using the $_POST method?
  6. You guys are right on the money again. Odviously I'm pretty new to PHP and did not even think about putting a $_POST within a while statement. Thanks again for all the help!
  7. I tried adding in the quotation marks $row = mysql_fetch_array($result); if ($row['answer']=='$answer$i') { I had to add quotes around $answer$i because it gave me an error. I think the correct handeling might be '$answer'.'$i' to combine the two variables, I have not had to do this before though
  8. The data is AlphaNumeric, actually just letters.
  9. I created a quiz, when it is submitted, I want to correct it using a loop, unfortunatly, the code I wrote is not working. $limit=$_POST['limit']; $question1=$_POST['question1']; $answer1=$_POST['answer1']; $question2=$_POST['question2']; $answer2=$_POST['answer2']; $question3=$_POST['question3']; $answer3=$_POST['answer3']; $i=1; while ($i<=$limit){ $sql="SELECT answer FROM writtenqs WHERE numquestion='$question$i'"; $result=mysql_query($sql); $row = mysql_fetch_array($result); if ($row[answer]==$answer$i) { $correct++; $qs++; echo "Question $i was correct."; } else { $qs++; echo "Question $i was wrong."; } $i++; } echo "Your score is $correct/$qs."; Am I just missing something, or is this not the correct way to do it. I have tried the code with actual numbers, i.e. question1,answer1 and it worked correctly. Thanks
  10. It's been a long day. I was missing a </table> and that messed it all up!
  11. i have a while statement in my code so I can output an array of variable lenght. The only problem is that the page does not display in the correct order, I.E. my footer comes before the output of the while statement, any way to fix this. Here is the php code: sql = "SELECT * FROM `writtenqs` ORDER BY RAND() LIMIT 3"; $result=mysql_query($sql); echo "<form id='form1' name='form1' method='post' action='insttest2.php'> <table width='100%' border='1'>"; $i=1; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td width='13%' scope='row'>$row[code]</td>"; echo "<td width='87%'>$row[lic] </td>"; echo " </tr>"; echo "<tr>"; echo "<td></td>"; echo "<td>$row[question]</td>"; echo "</tr>"; echo "<tr>"; echo "<th scope='row'> </th> <td> <p> <label> <input type='radio' name='answer'.$i value='A' id='RadioGroup1_0' />$row[oneanswer]</label> <br /> <label> <input type='radio' name='answer'.$i value='B' id='RadioGroup1_1' /> $row[twoanswer]</label> <br /> <label> <input type='radio' name='answer'.$i value='C' id='RadioGroup1_2' /> $row[threeanswer]</label> <br /> <input name='question#'.$1.' type='hidden' value='$row[numquestion]' /> </p> </td> </tr>"; $i++; } echo "<input name='Submit' type='button' value='Submit' /> </form>"; ?> Thanks[/code]
  12. Thanks for the help. Now I just have to put it together, then I'll probably be back asking for somemore help.
  13. So is using a sessions a better/safer way to go? will doing that slow my site down a lot if multiple people are taking a quiz at once?
  14. The last response if what I was thinking about doing, but instread of having two pages, use one page with cookies where when the quiz is submitted a cookie will be set with whether each question was right or wrong. Then I was going to use If statements to either display that the question was right or wrong and have the percentage at the end. I'm going to try to look up some javascipts that I can modify so I can get around using the cookies.
  15. Cool, so it sounds like I should look into AJAX a little but starting to set it up with PHP and MySQL should work fine. As far as learning some AJAX, any suggestions on a good place? w3schools.com?
  16. I am thinking about develping a quiz for my website. I have an idea of how to develope it using PHP, cookies, and a mysql database; but I was wondering if there was a better or more elegant way of doing it. I was going to set a cookie to store the quiz answers then check them when the person "submitted" the quiz. Also, I was not sure how to randonly select questions from my database using php. Is there some way to modify a loop? Would it be better to do this in another language such as Java? Thanks for the ideas. I do not want to spend a whole bunch of time working on this just to find out I was doing it the hard way.
  17. Cool so it would go something like switch('lic') { case yyyy: echo" we need more info"; break; case xxxx: echo" we need more info"; break; default: echo "no more info needed"; } I'll plug it in, thanks, looks like exactly what I was looking for!
  18. I am working on a form that depending on what a person selects form a dropdown menu, more information might or might not be required. If more info is required I have an IF statement, but is no information is required, I just have a submit button. Is there an elegant way to post a message, like "No furthur info is needed" without having to make IFs for every selection from the dropdown menu? Here is the current: <?PHP $lic=$_POST['lic'] if ('lic'== yyyy) {echo "<input type='text' name='moreinfoy' id='moreinfoy' /> </label>" } if ('lic'== xxxx) {echo "<input type='text' name='moreinfox' id='moreinfox' /> </label>" } echo " <input type='submit' name='Submit' id='Submit' value='Submit' /> </label> </p> </form>"; ?> THanks
  19. That was stupid! I was testing the database, and ended up having the table keys be the same, I change some of the inputs and it works. learned my lesson about including error reporting, thanks for all the help!
  20. It looks like you have an extra entry with $country. This code might work. $subject=$business; $subject=$country; $headers=From: $name <$email>\r\nReply-To: $email\r\nReturn-Path: $email\r\nCc: $email\r\n; $mailsnd=mail("$toaddress","$subject","$message","$headers");
  21. I am trying to save information from a form in an 'Endorsementlog' table. The only problem is that only the first option of "lic" will write to the database. All the other options still work and set "lic" to whatever it is supposed to be, but will not write to the table. echo "<form id='form1' name='form1' method='POST' action='endorsementform.php'> <p> <input name='firstName' type='hidden' id='firstName' value='$row[firstName]' /> <input name='lastName' type='hidden' id='lastName' value='$row[lastName]' /> </p> <p>Endorsement:<br /> <select name='lic' id='lic'> <option>Pre-Solo Aeronautical Knowledge</option> <option>Pre-Solo Flight Training</option> <?php $today=date("Y/m/d"); $make=$_POST['make']; $lic = $_POST['lic']; $student=$_POST['student']; $sex = $_POST['sex']; $CFI=$_POST['CFI']; $expireip=$_POST['expireip']; $firstName=$_POST['firstName']; $lastName=$_POST['lastName']; include("endorsementlog.inc"); // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); //write to instructor log mysql_query("INSERT INTO $tbl_name (Username, Date, Student, Endorsement) VALUES ('{$_SESSION['myusername']}','$today', '$student','$lic')"); What am I doing wrong?
  22. Just found that missed }. Thanks for the help!
  23. Thanks, i got to that code. But I am still getting the error message:"Parse error: parse error, unexpected $ in ... on line 233." Line 233 is after the last line of the code. I think this means I probably have an undefined variable somewhere.
  24. I added the {, but am getting the message:"Parse error: parse error, unexpected '.' " if I take out the '.', will it still sequence to the next row? Here is the current code. while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['Date'] . "</td>"; echo "<td>" . $row['Student'] . "</td>"; echo "<td>" . $row['Endorsement'] . "</td>"; if (. $row['Passed?']== 'null') { echo"<form id='elog' name='form2' method='post' action=''> <select name='Passed?' id='Passed?'> <option>Yes</option> <option>No</option> </select> </form>"; } else { echo "<td>" . $row['Passed?'] . "</td>"; } echo "</tr>"; echo "</table>";
×
×
  • 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.