Jump to content

facarroll

Members
  • Posts

    106
  • Joined

  • Last visited

Everything posted by facarroll

  1. Since my remote hosting server was recently migrated I am receiving an error message generally which goes like this Warning: session_start() [function.session-start]: open(c:/wampserver/tmp/session_file_name, O_RDWR) failed: No such file or directory (2) in /home/safetyte/public_html/portal/woodwork_sub/ws_member_profile.php on line 2 Lines 1 and 2 are <?php session_start(); This message is coming from the remote server but refers to a folder on my local computer (c:/wampserver/tmp) which is in fact the correct path for saving on the testing server. You can see this message is displayed on any computer (yours) by linking to http://www.safetytestingonline.com/portal/woodwork_sub/ws_member_profile.php . Any help would be appreciated. My webhost isn't doing much for me.
  2. Oh my! I've just read your post more carefully. I couldn't see the forest for the trees. I'll test this, but I think it looks good. Why didn't I see that?
  3. I should have explained the situation better. The SELECT takes an existing student result to a quiz from the database where (passState will always equal either pass (1) or fail (0). I want to allocate a score to each result. The score can be any value for a pass and a different value for a fail. So passState being 1 can be multiplied by $pass to get a score. I want to be able to give a student a mark for attempting, even though he fails, So in this event, passState can be multiplied by $fail, but because it's value is already 0, I add 1 to passState to enable the multiplication. I hope this is clearer.
  4. I have the following SELECT statement that does not show an error, but it's not working correctly, either. I suspect the CASE is not correct, but where? $query = mysql_query("SELECT users.id, quiz.userId, quiz.family, quiz.quizTitle, quiz.userGroup, quiz.passState, SUM(CASE WHEN quiz.passState=1 THEN quiz.passState * '".$pass."' ELSE (quiz.passState+1) * '".$fail."' END) AS total FROM quiz, users WHERE quiz.userIdRec = users.id AND quiz.addDate BETWEEN '".$start_date."' AND '".$end_date."' AND users.egroup='".$egroup5."' AND quiz.managerId='".$userid."' GROUP BY quiz.userId, quiz.quizTitle ORDER BY quiz.family, quiz.addDate") or die(mysql_error()); The values for the variables are dates and simple numbers. Nothing wrong with those. I suspect the syntax SUM(CASE WHEN quiz.passState=1 THEN quiz.passState * '".$pass."' ELSE (quiz.passState+1) * '".$fail."' END) AS total . passState always has the value '1' or '0'. I want to be able to derive a value from each which is a product of (in the first case) passState by the value in $pass. In the second case, I also want to calculate a value based on passState when it = '0', by simply adding '1' and multiplying by the value contained in the variable $fail. Can anyone see what is wrong with the SELECT?
  5. Thanks to pbs. This worked. $sql = " SELECT quiz.*, users.id, users.userGroup, users.family, users.given FROM quiz, users WHERE quiz.userIdRec = users.id AND (quiz.quizTitle LIKE '%".$strInfo."%' OR quiz.userId LIKE '%".$strInfo."%' OR quiz.userGroup LIKE '%".$strInfo."%') AND quiz.managerId = '".$userid."' AND users.userGroup != 'exStudent' ORDER BY users.family, users.given, quiz.quizTitle, quiz.addDate, quiz.passState ASC ";
  6. I have a search box which sets a choice out of three "sounds like" inputs. The variable which represents these is $strInfo . It should work but doesn't select anything, though there is no error message. I suspect the problem might be "AND WHERE". $sql = "SELECT quiz.*, users.id, users.userGroup, users.family, users.given FROM quiz,users WHERE quiz.userIdRec=users.id AND WHERE (quiz.quizTitle LIKE '%".$strInfo."%' OR quiz.userId LIKE '%".$strInfo."%' OR quiz.userGroup LIKE '%".$strInfo."%') AND quiz.managerId = '1' AND users.userGroup != 'exStudent' ORDER BY users.family, users.given, quiz.quizTitle quiz.addDate, quiz.passState ASC "; Can anyone suggest a correction?
  7. Actually had to tweak this a bit more, because on cycling through, a later Replace was working off the wrong code. I had to do this; //Updates Result data with formatting to fix column widths in results display $sql = "UPDATE quiz SET"; $sql = $sql." Result = REPLACE(Result,"; $sql = $sql." '<table border=1 bordercolor=#88BBDD cellpadding=0 cellspacing=0 width=100% ',"; $sql = $sql." '<table border=1 bordercolor=#88BBDD cellpadding=3 cellspacing=0 width=100% '"; $sql = $sql." )"; $sql = $sql." WHERE `managerId` = '$managerId' AND `userIdRec` = '$userIdRec' AND `quizId` = '$quizId' AND `quizTitle` = '$quizTitle' "; $rs = mysql_query($sql); $sql = "UPDATE quiz SET"; $sql = $sql." Result = REPLACE(Result,"; $sql = $sql." '<td><font size=2>Question<',"; $sql = $sql." '<td width=34%><font size=2>Query<')"; $sql = $sql." WHERE `managerId` = '$managerId' AND `userIdRec` = '$userIdRec' AND `quizId` = '$quizId' AND `quizTitle` = '$quizTitle' "; $rs = mysql_query($sql); $sql = "UPDATE quiz SET "; $sql = $sql." Result = REPLACE(Result,"; $sql = $sql." '<td><font size=2>Question Type<',"; $sql = $sql." '<td width=8%><font size=2>Question Type<')"; $sql = $sql." WHERE `managerId` = '$managerId' AND `userIdRec` = '$userIdRec' AND `quizId` = '$quizId' AND `quizTitle` = '$quizTitle' "; $rs = mysql_query($sql); $sql = "UPDATE quiz SET"; $sql = $sql." Result = REPLACE(Result,"; $sql = $sql." '<td><font size=2>Points',"; $sql = $sql." '<td width=2%><font size=2>Points')"; $sql = $sql." WHERE `managerId` = '$managerId' AND `userIdRec` = '$userIdRec' AND `quizId` = '$quizId' AND `quizTitle` = '$quizTitle' "; $rs = mysql_query($sql); $sql = "UPDATE quiz SET"; $sql = $sql." Result = REPLACE(Result,"; $sql = $sql." '<td><font size=2>User',"; $sql = $sql." '<td width=27%><font size=2>User')"; $sql = $sql." WHERE `managerId` = '$managerId' AND `userIdRec` = '$userIdRec' AND `quizId` = '$quizId' AND `quizTitle` = '$quizTitle' "; $rs = mysql_query($sql); $sql = "UPDATE quiz SET"; $sql = $sql." Result = REPLACE(Result,"; $sql = $sql." '<td><font size=2>Correct Answer',"; $sql = $sql." '<td width=27%><font size=2>Correct Answer')"; $sql = $sql." WHERE `managerId` = '$managerId' AND `userIdRec` = '$userIdRec' AND `quizId` = '$quizId' AND `quizTitle` = '$quizTitle' "; $rs = mysql_query($sql); $sql = "UPDATE quiz SET "; $sql = $sql." Result = REPLACE(Result,"; $sql = $sql." '<td><font size=2>Result',"; $sql = $sql." '<td width=2%><font size=2>Result')"; $sql = $sql." WHERE `managerId` = '$managerId' AND `userIdRec` = '$userIdRec' AND `quizId` = '$quizId' AND `quizTitle` = '$quizTitle' "; $rs = mysql_query($sql); //Feedback ... if ($rs) { echo "feedMsg=Data has been posted successfully"; } else { echo "feedMsg=Failed to post data to database"; } ?>
  8. I have found a very very ugly solution. I cannot do anything about the improper insertion of the data as it comes from a second party, so Illusion's solution, though correct, was not an option. The solution was to write several REPLACE scripts and run them in sequence. I did this; UPDATE quiz SET Result = REPLACE(Result, '<table border=1 bordercolor=#88BBDD cellpadding=0 cellspacing=0 width=100% ', '<table border=1 bordercolor=#88BBDD cellpadding=3 cellspacing=0 width=100% ' ) WHERE id = '92'; UPDATE quiz SET Result = REPLACE(Result, '<td><font size=2>Question', '<td width=32%><font size=2>Question') WHERE id = '92'; UPDATE quiz SET Result = REPLACE(Result, '<td><font size=2>Question Type', '<td width=10%><font size=2>Question Type') WHERE id = '92'; UPDATE quiz SET Result = REPLACE(Result, '<td><font size=2>Points', '<td width=2%><font size=2>Points') WHERE id = '92'; UPDATE quiz SET Result = REPLACE(Result, '<td><font size=2>User', '<td width=27%><font size=2>User') WHERE id = '92'; UPDATE quiz SET Result = REPLACE(Result, '<td><font size=2>Correct Answer', '<td width=27%><font size=2>Correct Answer') WHERE id = '92'; UPDATE quiz SET Result = REPLACE(Result, '<td><font size=2>Result', '<td width=2%><font size=2>Result') WHERE id = '92'; This enabled me to simply not replace the parts of the HTML that included backslashes, thus bypassing the problem. Thanks for everyone's help.
  9. I've tracked the problem to the existence of the three occurrances of backslash. How can I deal with that?
  10. I revised the code to this. UPDATE quiz SET Result = REPLACE(Result, '<table border=1 bordercolor=#88BBDD cellpadding=3 cellspacing=0 width=100% style=\'border-collapse: collapse\'> <tr bgcolor=#B1D2E9> <td><font size=2>Question</font></td> <td><font size=2>Question Type</font></td> <td><font size=2>Points</font></td> <td><font size=2>User\'s Response(s)</font></td> <td><font size=2>Correct Answer</font></td> <td><font size=2>Result</font></td> </tr>', '<table border=2 bordercolor=#88BBDD cellpadding=3 cellspacing=0 width=100% style=\'border-collapse: collapse\'> <tr bgcolor=#B1D2E9> <td width=30%><font size=2>Question</font></td> <td width=10%><font size=2>Question Type</font></td> <td width=3%><font size=2>Points</font></td> <td width=27%><font size=2>User\'s Response(s)</font></td> <td width=27%><font size=2>Correct Answer</font></td> <td width=3%><font size=3>Result</font></td> </tr>') where managerId='1' It still does not work. Is there a syntax error?
  11. Thanks illusion. I have since trimmed the spaces out, but to no avail. The script does not seem to be able to select a record, thus there is no REPLACE made.
  12. And anyway, there is a WHERE clause in the original code.
  13. It might be dangerous if it worked, but it doesn't. That's the problem. Why doesn't it work?
  14. Hi all. I am trying to replace a string of HTML contained in a field. I inherited this data as it is. I want to format a table displaying the data in Result so that the columns display with controlled widths. The field is named Result and is a mediumtext type. The table is named quiz. Here is my code. UPDATE quiz SET Result = REPLACE(Result, ' <table border=1 bordercolor=#88BBDD cellpadding=0 cellspacing=0 width=100% style=\'border-collapse: collapse\'> <tr bgcolor=#B1D2E9> <td><font size=2>Question</font></td> <td><font size=2>Question Type</font></td> <td><font size=2>Points</font></td> <td><font size=2>User\'s Response(s)</font></td> <td><font size=2>Correct Answer</font></td> <td><font size=2>Result</font></td> </tr>' , '<table border=1 bordercolor=#88BBDD cellpadding=0 cellspacing=0 width=100% style=\'border-collapse: collapse\'> <tr bgcolor=#B1D2E9> <td width=\'29%\'><font size=2>Question</font></td> <td width=\'13%\'><font size=2>Question Type</font></td> <td width=\'5%\'><font size=2>Points</font></td> <td width=\'29%\'><font size=2>User\'s Response(s)</font></td> <td width=\'29%\'><font size=2>Correct Answer</font></td> <td width=\'5%\'><font size=2>Result</font></td> </tr>' ) WHERE userId LIKE 'Mary%';` There must be something wrong because it doesn't work. The query is accepted by mysql but the data does not change. I suspect I have to escape some of the HTML somewhere. Can anyone help?
  15. Requinix. I did this... <?php if ("{$row['passState']}" == 0) { ?> <script language="javascript" type="text/javascript <!-- var newwindow; function popup() { newwindow = window.open('check/check.php?quizTitle=<?php echo urlencode($quizTitle); ?>','_blank','scrollbars=yes,top=0,left=0,width='+screen.width+',height='+screen.height); if (window.focus) {newwindow.focus()} } //--> </script> <?php echo '<form><input type="button" onClick="popup()" value="Check your answers"></form> '; } ?> And now I have a lovely full-screen popup window without standard controls. I have included a script to allow the user to return to the previous page. Despite the browser problems, I think this problem is solved.
  16. I changed the code as follows as was suggested by behicthebuilder. It works well now on Chrome, Firefox and iexplore, but Safari, Netscape and Opera open the page but do not deliver any dynamic content. I'm using <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> Can anyone make a suggestion? <?php // code associated with a database query precedes this if ("{$row['passState']}" == 0) { ?> <script language="javascript" type="text/javascript" > <-- var newwindow; function popup() { newwindow = window.open('check/check.php?quizTitle=".urlencode($quizTitle)."','_blank','scrollbars=yes,top=0,left=0,width='+screen.width+',height='+screen.height); if (window.focus) {newwindow.focus()} } //--> </script> <?php echo '<form><input type="button" onClick="popup()" value="Check your answers"></form> '; //echo "<A HREF=\"check/check.php?quizTitle=".urlencode($quizTitle)."\" onClick=\"return popup(this, 'thoughts', 'scrollbars=1'); window.moveTo(0,0); window.resizeTo(screen.width,screen.height-100);\">Check your answers</A>."; } ?>
  17. Thanks. That looks good. Cannot try out till tonight. I'll reply further then.
  18. Have you tried preg_replace and allowing say only letters and numbers? Something like this? <?php $userName = preg_replace("/[^A-Z a-z0-9]/", "", $_POST['userName']); $userPwd = preg_replace("/[^A-Za-z0-9]/", "", $_POST['userPwd']); $postText = preg_replace("/[^A-Za-z0-9]/", "", $_POST['postText']); ?>
  19. I believe this is a PHP problem rather than a javascript one, but stand to be corrected. The following code shows two echo statements, with the second one commented out. The uncommented statement inside the javascript will not work, because while it calls up the check.php file it does not send the associated parameters correctly. I have left the commented echo in because it works perfectly. What's wrong? I know that javascript works client side, but the relevant php code has already run so the javascript should work. <?php // code associated with a database query precedes this if ("{$row['passState']}" == 0) { ?> <script language="javascript" type="text/javascript" > <-- var newwindow; function popup() { newwindow = window.open('check/check.php?quizTitle=".urlencode($quizTitle)."','_blank','scrollbars=yes,top=0,left=0,width='+screen.width+',height='+screen.height); if (window.focus) {newwindow.focus()} } //--> </script> <?php echo '<form><input type="button" onClick="popup()" value="Check your answers"></form> '; //echo "<A HREF=\"check/check.php?quizTitle=".urlencode($quizTitle)."\" onClick=\"return popup(this, 'thoughts', 'scrollbars=1'); window.moveTo(0,0); window.resizeTo(screen.width,screen.height-100);\">Check your answers</A>."; } ?> My justification for presenting a full screen popup for students is so that they can see answers they have given in an earlier quiz. I find that if their popup is just a window over their working page, they can use the popup to just fill in their answers on a second attempt. Full screen mode will limit this.
  20. Thanks for the help both friends. The path difference is intentional, because the files are held in different tsting folders. The suggested change did not alter anything. I'll keep trying a few things.
  21. I think this is a PHP topic rather than Javascript. Can anyone tell me why this code cannot find the page (404 Not Found) <?php if ("{$row['passState']}" == 0) { ?> <script language="javascript" type="text/javascript" > <-- var newwindow; function popupgo() { newwindow = window.open('check.php?quizTitle=<?php ".urlencode($quizTitle)."; ?>','_blank', 'scrollbars=yes,top=0,left=0,width='+screen.width+',height='+screen.height); if (window.focus) {newwindow.focus()} } //--> </script> <?php echo "<form><input type='button' onClick='popupgo()' value='Popup'></form>"; } ?> when this test code works fine? Both files are PHP. <?php ?> <head> <script language="javascript" type="text/javascript" > <-- var newwindow; function popupgo() { newwindow = window.open('check/check.php?quizTitle=<?php '.urlencode($quizTitle).'; ?>','_blank', 'scrollbars=yes,top=0,left=0,width='+screen.width+',height='+screen.height); if (window.focus) {newwindow.focus()} } //--> </script> </head> <body> <form> <input type="button" onClick="popupgo()" value="Popup"> </form> </body> <?php ?>
  22. You cannot derive information from the punch_time field as it stands because there is no identification of each time as an arrival or a departure. You need something like this in your database. Userid Date arrive_Punch_time depart_punch_time 1 01-01-2012 09:00 am 09:10 am 1 01-01-2012 09:15 am 09:20 am 1 01-01-2012 11:02 am 11:30 am 1 01-01-2012 12:59 pm 13:10 pm 1 01-01-2012 15:55 pm 16:10 pm 1 01-01-2012 17:59 pm 18:30 pm 2 01-01-2012 09:10 am 9:50 am
  23. I have to reply that wile I did try your useful advice, it quite simply did nothing.
  24. I CAN see how dumb you are, but can YOU see how offensive you are as well.
  25. Thanks AyKay for your kind help. I was able to solve this problem by working through your suggestion. While your solution did not work as it stood, I realised that if I included a hidden type with name= 'submit' in the input form, then there would be a point to the isset function. Many thanks for your other helpful comments as well. I'll work through them.
×
×
  • 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.