Jump to content

stockton

Members
  • Posts

    319
  • Joined

  • Last visited

    Never

Everything posted by stockton

  1. Please tell me more. How would you code it to still call submit_click at the appropriate time ie when the Update button is clicked?
  2. I have the following code in a html page and I need to know how to code the line starting <a href="events.php"....... to get it to work rather than call the onclick="submit_click() on the line above. The submit_click is obviously a JavaScript function that I do not want to run when the Back button is clicked. <input type=button value="Update" onclick="submit_click()"> <a href="events.php?EventID=0"><BUTTON TYPE="submit">Back</BUTTON></a>
  3. If I had applied my mind to the problem before asking the question I would have realised that a semaphore cannot survive the program that created it. Therefore calling the program via Ajax was a bit thick. Semaphores are used to stop more than one user from running the same program at the same time.
  4. Which line? If your query is the SQL line I would write it as follows. $c=mysql_query("SELECT * FROM `users` WHERE status='Alive' ORDER BY `users`.`health` ASC LIMIT 0, 10;");
  5. I am attempting to set and clear semaphores from php code called via Ajax and the setting seems to be working but the clear fails with the following message. Warning: sem_release() [function.sem-release]: SysV semaphore 2 (key 0x6b) is not currently acquired The php I am using is:- <?php //This function takes a GUUID like one generated from the /usr/bin/uuidgen program //(e.g. ab684e1c-15fa-4241-aa53-65dd3bc55bd6) and strips out all the alpha- characters, //It will then add together all the numbers and return that for use as a VERY semi-unique key. //This is done this way for the fact that sem_get() (which is what this was written for) only takes integers for //the key value. function GUUIDtoInt($p_GUUID) { $retVal = 0; $stack = array(); for ($index = 0; $index < strlen($p_GUUID); $index++) { $char = $p_GUUID{$index}; if (is_numeric($char)) { array_push($stack, $char); } } $topChar = array_pop($stack); $decimalPower = 1; while ($topChar != NULL) { $temp = (int)$topChar; $retVal += $temp; $topChar = array_pop($stack); } return $retVal; } // Program starts here $Command = $_REQUEST["Command"]; $intKey = GUUIDtoInt('b6379c52-d96d-418b-83c3-8aedb5e6cf95'); echo "Testing semaphore code ".$Command." ".$intKey."<br/>"; if (!$sem_id = sem_get($intKey)) { $Message="Could not get ID for the semaphore."; echo $Message; exit; } if ($Command=="set") { $Message="Got semaphore ID; acquiring..."; if (!sem_acquire($sem_id)) { $Message.=" failed."; echo $Message; exit; } else { $Message.=" OK Got it.".$sem_id; echo $Message; exit; } } else { if (!sem_release($sem_id)) { $Message.=" Release for ".$sem_id." failed. ".$intKey; echo $Message; exit; } $Message="Semaphore released. Other scripts should be able to get it now."; echo $Message; exit; } ?> What am I not understanding and therefore have done wrong?
  6. OK I missed your implied replace and have now done that and am getting the results I wanted. Thank you.
  7. I have removed the " onSubmit='return false; " from the form definition in the html and now I get the final message but not those messages inbetween. The form definition now looks like:- <form action="semaphoreTest.php" method="get" name="SemaphoreTest" id="SemaphoreTest" > The messages I am also expecting but not getting are:- "Uninitialized........" "Loading........" "Loaded........" and "Interactive........" from the Diva.js script. BTW You can actually see the programs/scripts in action at http://www.stockton.co.za/semaphoreTest.html
  8. Still nothing. Not even an alert from the submit_click() javascript function.
  9. Theoretically I should see messages pop up in the HTML page but nothing occurs.
  10. The following very simple scenario is not working for me. Please help. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <title>Test PHP Semaphore</title> <meta name="author" content="Alf Stockton"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="Mon, 22 Jul 2000 11:12:01 GMT"> <script language="JavaScript" type="text/javascript" src="js/Diva.js"></script> </head> <body> <center> <h2>Test PHP Semaphore</h2> </center> <form action="semaphoreTest.php" method="get" name="SemaphoreTest" id="SemaphoreTest" onSubmit='return false;' > <center> <input type=hidden name="submit1" id="submit1" value="<?php echo $Ding; ?>" > <P> <input type=submit value="Submit" onclick="submit_click()"> </p> <div id="Boodskap";></div> <!-- <input type=text readonly name="Boodskap" id="Boodskap" value ='<?php echo $Message ?>'>; --> </center> </FORM> </body> </html> <script language=javascript> function submit_click() { alert "submit_click()"; var bError = false; var strErrorMsg = ""; var Command = "semaphoreTest.php"; progExe(Command); return false; } the semaphoreTest.php looks like:- <?php { $intKey = GUUIDtoInt('b6379c52-d96d-418b-83c3-8aedb5e6cf95'); // echo "Testing semaphore code<br/>"; if (!$sem_id = sem_get($intKey)) { $Message="\nX\n\nCould not get ID for the semaphore."; echo $Message; exit; } else { $Message="\nX\n\nGot semaphore ID; acquiring..."; flush(); if (!sem_acquire($sem_id)) { $Message.=" failed."; echo $Message; exit; } else { $Message="\nX\n\nOK got it. Sleeping for 20 seconds, then releasing."; flush(); sleep(20); sem_release($sem_id); $Message.="Semaphore released. Other scripts should be able to get it now.";i echo $Message; exit; } } } ?> and the Diva.js is:- function getXMLHttpRequest () { try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}; try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}; try { return new XMLHttpRequest(); } catch(e) {}; return null; } // Make the XMLHttpRequest object var xhr = getXMLHttpRequest(); function progExe(CommandString) { xhr.open("GET", CommandString, true); xhr.onreadystatechange = ServerResponse; xhr.send(null); } function ServerResponse() { alert("entered ServerResponse()"); /* The full list of the readyState values is as follows: * 0 (uninitialized) * 1 (loading) * 2 (loaded) * 3 (interactive) * 4 (complete) */ if(xhr.readyState == 0) { document.getElementById("Boodskap").innerHTML = "Uninitialized........"; } else if(xhr.readyState == 1) { document.getElementById("Boodskap").innerHTML = "Loading........"; } else if(xhr.readyState == 2) { document.getElementById("Boodskap").innerHTML = "Loaded........"; } else if(xhr.readyState == 3) { document.getElementById("Boodskap").innerHTML = "Interactive........"; } else if(xhr.readyState == 4) { if (xhr.status == 200) { var parts = xhr.responseText.split("\n"); if (parts[1] == "X") { alert(parts[3]); } else window.location=parts[3]; document.getElementById("Boodskap").innerHTML = ""; } } }
  11. I did not believe that enabling the "display_errors = on" in your php.ini will help show mssql messages and in fact when I tested your suggestion nothing changed. I still only get corbins suggested Error:
  12. I'll try your suggestion even though I have the same version of mssql on my desktop as I have on my laptop and the desktop works fine.
  13. As you suspected adding your code and now all I get is "Error. " host/username/password are all correct but I do not understand your "Like, you aren't trying to use localhost or something on the laptop are you?". If you mean am I browsing to localhost I am and the relationship between localhost and 127.0.0.1 is setup in my hosts file; did I mention that this system is on Windows. If you mean am I using localhost in my configuration file to point to the database, yes I am. and I am attempting to access the system(on my laptop) from my laptop.
  14. I should have seen that. I am sorry to have wasted your time.
  15. Please tell me what "ERROR 1305 (42000): FUNCTION dotproject.EFT does not exist" produced by the following means & how I fix it. mysql> SELECT LEFT(project_name,50) AS 'Project', -> /*== Decode Project Status == */ -> CASE project_status -> WHEN 1 THEN LEFT('Incoming/Approval',20) -> WHEN 2 THEN LEFT ('Planning',20) -> WHEN 3 THEN LEFT('In Progress',20) -> WHEN 4 THEN LEFT('QC/UAT',20) -> WHEN 5 THEN LEFT('Complete',20) -> WHEN 6 THEN LEFT('On Hold',20) -> WHEN 7 THEN EFT('Archived',20) -> END AS 'Status' -> from projects; ERROR 1305 (42000): FUNCTION dotproject.EFT does not exist
  16. Unfortunately all that, that gives me is a blank screen.
  17. I do have the client libraries on my laptop. I do have mssql extensions enabled in PHP.ini and MSSQL gives no error message that I am aware of. All I get is the "Unable to connect to T4T database" from my own code(see below) & I am aware of the die on the connect line and I have coded that many different ways but mssql refuses to share any error messages with me. $link = mssql_connect($servername, $dbusername, $dbpassword) or die("Unable to connect to T4T database"); if (!(mssql_select_db($dbname, $link))) { echo "Error in DBConnect() = " . mssql_get_last_message(); sprintf($Message, "At %d in %s Could not select %s at %s as %s",__LINE__, __FILE__, $dbname, $servername, $dbusername); trigger_error(E_USER_ERROR, $Message); exit; }
  18. The following code consistently works on all PCs tried on except my laptop. Please give me some hints on why this may happen. global $dbservertype, $servername, $dbusername, $dbpassword, $dbname, $link; $link = mssql_connect($servername, $dbusername, $dbpassword) or die("Unable to connect to T4T database");
  19. I am currently trying to install Track+ on my clients Ubuntu 8.04 server and as I am not a Java programmmer I am having issues. Track+ is a web based issue tracking software and project management software and the thought crossed my mind that there are probably alternatives products that are somewhat easier to install. Suggestions please.
  20. I suspect that the problem is that the 1st program is not submitting a form but rather doing a call to the 2nd machine on a different server. Therefore the code should be altered as follows:- header("Location: http://motrain.dev.sharing.org.za/test/dong.php"); should now become :- header("Location: http://motrain.dev.sharing.org.za/test/dong.php?uname=$uname&passwd=$passwd"); and therefore the 2nd program should be altered to:- $uname = $_GET["uname"]; $passwd = $_GET["passwd"]; from:- $uname = $_POST["uname"]; $passwd = $_POST["passwd"]; This is all because session variables are only available on the 1st machine and any data required on the 2nd machine must be passed via $_GET rather than form submission.
  21. I have created a program using the example at http://www.tizag.com/phpT/examples/formfinale.php as follows:- <?php /* * A program, written by Alf Stockton, to proove that it is possible to run * a program on a remote site from a program on this site, passing to the * remote program whatever parameters it requires to run successfully. * * This then for the Khulisa site, removes the requirement for memcache * or similar. */ ob_start(); if (!empty($_REQUEST['submit'])) $Button = ($_REQUEST['submit']); else $Button = ''; // echo "Button = ".$Button." ??"; if ($Button == 'Submit') { $Button = $_REQUEST['submit']; session_start(); ob_start(); $quote = 0x27; // authenticate. if (!get_magic_quotes_gpc()) { $_REQUEST['uname'] = addslashes($_REQUEST['uname']); } $uname = $_REQUEST['uname']; $passwd = strip_tags($_REQUEST['passwd']); $passwd = stripslashes($_REQUEST['passwd']); $date = date('Y-m-d H:i:s'); $_SESSION['Usrname'] = $uname; $_SESSION['Passwrd'] = $passwd; $_SESSION['Date'] = $date; header("Location: http://motrain.dev.sharing.org.za/test/dong.php"); } else if ($Button == 'Clear') // Clear Previous { $Ding = 0; $uname = ""; $passwd = ""; $date = ""; } ob_end_flush(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <head> <title>Login</title> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="Mon, 22 Jul 2000 11:12:01 GMT"> <script language="JavaScript" type="text/javascript" src="js/Diva.js"></script> </head> <BODY ONLOAD="BodyOnLoad()"> <form name='logon' id='logon' method='POST' action='<?php echo $PHP_SELF; ?>' > <table align="center" border="3" cellspacing="0" cellpadding="3"> <tr><td>Username:</td><td> <input type="text" name="uname" id="uname" maxlength="40"> </td></tr> <tr><td>Password:</td><td> <input type="password" name="passwd" id="passwd" maxlength="50"> </td></tr> <input type=hidden name="submit1" id="submit1" value="<?php echo $Ding; ?>" > </td></tr> </table> <center> <p> <input type="submit" name="submit" value="Submit"> <input type="submit" name="submit" value="Clear"> <input type="submit" name="submit" value="Back"> </p> </center> </form> </body> </html> <script type="text/javascript"> function BodyOnLoad() { document.logon.uname.focus(); } </script> I now need to retrieve the entered data via <?php $uname = $_POST["uname"]; $passwd = $_POST["passwd"]; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <title>motrain's Test</title> <meta name="author" content="Alf Stockton"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="Mon, 22 Jul 2000 11:12:01 GMT"> </head> <h2>MOTRAIN's Test</h2> <center> Have a Good Day<?php echo " $uname with password $passwd." ?> </center> </body> </html> but do not get any data back. What have I done wrong?
  22. Is it possible to retrieve PHP session variables from a C or C++ cgi program? If so where should I start learning?
×
×
  • 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.