Jump to content

facarroll

Members
  • Posts

    106
  • Joined

  • Last visited

About facarroll

  • Birthday 08/11/1949

Contact Methods

  • Website URL
    http://www.safetytestingonline.com

Profile Information

  • Gender
    Male
  • Location
    Ballarat, Australia

facarroll's Achievements

Member

Member (2/5)

0

Reputation

  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.
×
×
  • 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.