Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About morrisjohnny

  • Rank
  • Birthday 01/29/1990

Contact Methods

  • AIM
  • MSN
  • ICQ
  • Yahoo
  • Skype

Profile Information

  • Location
    Berwick-Upon-Tweed, NE England, UK
  1. you can ignore this. It turns out they had been using a third party rewriting software and not mod re-write !
  2. I'm having problems migrating one client from web server to another. I have attached the current .htaccess in use at the bottom. On the current site visitinghttp://domain.com/index.php/about-ushttp://domain.com/index.php/news-eventshttp://domain.com/index.php/newsall return correct pageson the new website these pages load fine However going to this pagehttp://domain.com/index.php/news/23/87/Gardens-Opening-for-Leuchie-House-2012returns a Not Found The requested URK was not found on this server. (a side note which may help is)The hyperlinks on the live site shows links as index.php/about-us for example yet on the new site they are shown as index.php?page=about-us What could be causing this? the database/files and .htaccess files have all been brought across. .htaccess file <IfModule mod_rewrite.c>RewriteEngine onRewriteBase /leuchieRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.+)$ index.php?page=$1 [QSA]</IfModule> <IfModule mod_header.c>Header unset ETagFileEtag None</IfModule> <IfModule mod_deflate.c>AddOutputFilterByType DEFLATE text/css text/plain text/xml image/gif image/jpeg image/png</IfModule> <IfModule mod_expires.c><FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">ExpiresActive OnExpiresDefault "access plus 1 year"<IfModule mod_header.c> Header set Cache-Control "public"</IfModule></FilesMatch></IfModule>
  3. in order to migrate from MS SQL to MySQL you can just export from MS SQL and import into MySQL both support export and important and because they are both based on SQL they should function okay in terms of accessing the database depending on the functions you've used you may have more problems for exmaple MySQL can use Limit where's MS SQL does not as one example. You should not need to publish a MS SQL using an IP address. we have a ms sql server and a web host that is located in a DMZ the web host and still talk to our MS SQL database without any problems and that does not have a public IP. Either way the damage to either a MS SQL and a MySQL data will also ways be the same, someone gets access and gets access and either manipulates the data, sells it or deletes it whether is is MySQL or MS SQL !
  4. I'm currently working for a company who i'm assuming have a pre 4.1 MySQL as when i'm trying to connect with PHP 5.3.8 and it is complaining about the insecure authentication Now i've noticed you need to run the following commandSET old_passwords = 0;UPDATE mysql.user SET Password = PASSWORD('testpass') WHERE User = 'testuser' limit 1;SELECT LENGTH(Password) FROM mysql.user WHERE User = 'testuser'; FLUSH PRIVILEGES; However considering this database is accessed by a number of different systems if I run this command for one of the users will this affect all other users? as i'm not 100% certain what other software connect to this database (I know of 2 others). Without downgrading PHP or upgrading MySQL what other options do I have?create a new user just for PHP and run the command? or will it affect others users?
  5. so using timestamps how would i be able to identifiy midnight to 8:30 and 5:30 till midnight monday to friday? i now understand how the dates methods i'm using (thank you PHP) is converting everything from all the different values. I know this code is the worst i have ever seen and coded i just don't know the best way to do this. It's due for tomorrow hence why i'm 'just carrying on with the scruffy way' i will be going back and look to tidy this up. (that's why i'm interested in timestamps)
  6. Thanks theScientist yeah the cases above are what i'm trying to program. Whats the difference between timestamps and dates? the data has to be stored as a date. Working with dates/timestamps are probably my weakest point hence why i'm really struggeling with this. I've managed to almost get it working (so i think) however when i tried to convert date_format($start,'u') (start is a new DateTime object) it sets the unix time to be ZERO ?at the moment i'm putting in static data such as business opening hours but at point this will need to be from a database value. Here's my current code which is having problems convert from $start to unix stamp so i can remove out of hours timefunction strip_out_of_hours($start,$end){ if(date_format($start,'H')>'17'&&date_format($start,'i')>'30') $start=new DateTime(date('y-m-d H:i:s',strtotime("+1 day",strtotime(date_format($start,'y-m-d').' 08:30:00')))); if(date_format($start,'H')<'08'&&date_format($start,'i')<'30') $start=new DateTime(date('y-m-d H:i:s',strtotime(date_format($start,'y-m-d').' 08:30:00'))); if(date_format($end,'H')>'17'&&date_format($end,'i')>'30') $end=new DateTime(date('y-m-d H:i:s',strtotime(date_format($end,'y-m-d').' 17:30:00'))); if(date_format($end,'H')<'08'&&date_format($end,'i')<'30') $end=new DateTime(date('y-m-d H:i:s',strtotime("-1 day",strtotime(date_format($end,'y-m-d').' 17:30:00')))); $date_diff=(date_format($end,'d')-date_format($start,'d')); $time_diff=(date_format($end,'u')-date_format($start,'u')); echo 'Time Diff Begin'.$time_diff; for($i=$date_diff;$i!=0;$i--){ echo '<br />-'.$i.'--'.$time_diff; $test=getdate(date_format($start,'u')); if(getdate(date_format($start,'u'))==0||getdate(date_format($start,'u'))==6)//day is Sunday Remove 24 hours (full hours on sunday's date $time_diff=($time_diff-86400);//Removes 24 hours from the timestamp Because we are closed on Sundays else if(getdate(date_format($start,'u'))==1||getdate(date_format($start,'u'))==2||getdate(date_format($start,'u'))==3||getdate(date_format($start,'u'))==4||getdate(date_format($start,'u'))==5) //Get Mondays,Tuesdays,Wednesdays,Thursday and Fridays $time_diff=($time_diff-54000);//Removes 24 hours from the timestamp Because we are closed on Sundays } return '<br />'.date_format($start,'Y-m-d H:i:s').'|'.date_format($end,'Y-m-d H:i:s').'--------Hours Elapsed Inside Business Hours'.$time_diff; }
  7. Hello All.I'm currently working on a custom reporting function.What i'm looking todo is extract the total time elapsed ($start) for each ticket during business hours the business hours are:mon-fri: 8:30-17:30 So if a ticket was loggedMonday 8:00 and closed: Monday 9 it's 0.5 (half an hour because the SLA/Business hour states from 8:30)Monday 13:00 and closed: Tuesday 12:00 it's 9 (Because 23hours (actual time between create_time and date_completed) - 14(number of hours the SLA/Business hours does not run for = ))Friday 17:00 and closed: Monday 09:00 its 1 (again because our buiness hour stops on friday at 17:30 and re-starts from monday 08:30. Note some tickets are logged outside of business hours and some tickets may be closed outside business hours.If they are opened they need to be taken from when the business re-opens (as you'd expect)If they are closed they need to be taken from when the business closed. I'm currently calling a function called strip_out_of_ours($start,$end){ $start_month=date_format($start,'m'); $end_month=date_format($start,'m'); if(date_format($start,'H')>'17'&&date_format($start,'i')>'30')// if this has been logged after 17:30 but before midnight assign the date for tomorrow at 8:30 $start=date('y-m-d H:i:s',strtotime("+1 day",strtotime(date_format($start,'y-m-d').' 08:30:00'))); if(date_format($start,'H')<'08'&&date_format($start,'i')<'30')// if this has been logged before8:30 make it 8:30 $start=date('y-m-d H:i:s',strtotime(date_format($start,'y-m-d').' 08:30:00')); if(date_format($end,'H')>'17'&&date_format($end,'i')>'30') $end=date('y-m-d H:i:s',strtotime(date_format($end,'y-m-d').' 08:30:00')); if(date_format($start,'H')<'08'&&date_format($start,'i')<'30') $end=date('y-m-d H:i:s',strtotime("-1 day",strtotime(date_format($end,'y-m-d').' 08:30:00'))); return var_dump($start); }
  8. <?php //Start sessionsession_start(); //Include database connection detailsrequire_once('config.php'); //Array to store validation errors$errmsg_arr = array(); //Validation error flag$errflag = false; //Connect to mysql server$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);if(!$link) { die('Failed to connect to server: ' . mysql_error());} //Select database$db = mysql_select_db(DB_DATABASE);if(!$db) { die("Unable to select database");}//$email = $_SESSION['SESS_EMAIL']; //Select everythingmysql_query("SELECT * FROM members")or die(mysql_error()); //Update the hourly moneymysql_query("UPDATE members SET money=money+moneyhourly")?> try that (I've jsut removed where email = email)then load the page manually. is it updating anything/one result/zero result?In your config file does it check to see if the user is logged in or?
  9. Hello DubbelDam, Sorry i forgot last night it's in my phone to remind me tonight. Hax? it kind of died. but its still online i believe agian will pop back tonight with details. Try referencing the link directly for example http://www.(SERVERNAME)/mafiawarstest/moneyadd-exec.php you will need to of course make sure no log-in is required to this page. or no sessions are set as these will not be set by the serverbasically you want to do foreach($users as $user) mysql_query(UPDATE `tablename` SET 'money'='money'+$moneyamount where id=$user->id); there is a MUCH better way to do that but again thats from the top of my head. If you have msn/skype your welcome to skype/msn me i think i have ALOAD of files that could help you.
  10. depending on the type of hosting you are using depends on the answer Linux: Create a CronJob (there will be an option in the CPanel usually) http://en.wikipedia.org/wiki/CronWindows: Task in Task Scehule or their should be something simlar in the CPanel. At home (I'm at work) i created something that checked the last time the user logged in and then worked out how much more money they required. back in the day when i created a mafia game. i'm sure i have the scripts lieing around somewhere if i remeber i wil post back tonight ! (around 6 hours time)
  11. Solution SELECT * FROM (SELECT row_number() OVER (ORDER BY id ASC) as rownum, * FROM CPLogs /* Any Filtering In Here*/) as a WHERE a.rownum BETWEEN 10 AND 20 I've personally tested SELECT TOP 10 * FROM CPLogs WHERE id NOT IN (SELECT TOP 20 * id FROM CPLogs ORDER BY id ASC) ORDER BY id ASC Supplied by JustSomeGuy (Not Tested)Okay coming from MySQL i've become used to using Limit and Offset in order to create a nice pagination However as part of a project I've had to used MS SQL which of course does not have LIMIT so instead i'm using TOP . . . okay trying to use TOPas far as i'm awareThese two statements should create the same effect: SELECT * FROM table LIMIT 10,20 SELECT * FROM (SELECT 10 * FROM ( SELECT TOP 20 FROM table)as x)as y This is my result from running the second statement and moving to a new apge: SELECT * FROM ( SELECT TOP 10 * FROM ( SELECT TOP 10 id,userid,timestmp,page FROM CPLogs ORDER BY id asc )as x ORDER BY id asc)as y ORDER BY id ascand the next page shows:SELECT * FROM ( SELECT TOP 10 * FROM ( SELECT TOP 20 id,userid,timestmp,page FROM CPLogs ORDER BY id asc )as x ORDER BY id asc)as y ORDER BY id asc however the data that is shows is still the same. After a bit of research i then came across a row_num so i tried this however i could not get this to work either. (could not get the syntax correct) So i'm looking for pointers in the correct direction I'm using these variables incase they are of any use to anyone.$sLimit = (Top Limit) (this is 10 in both above statements)$sLimit2 = (Bottom Limit)$sWhere = is my where statement$sOrder = is my order by statement. Thanks Inadvance JohnnyPS. why can MS SQL not just support LIMIT and OFFSET? although it's a good eye opener.
  12. Hi firstly please excuse my stupidity hereRight before I ask, Please bare with me as I'm a total newbie to Java script/programming what everI've been given a task to take variables (currently using HTML as this ties in with other projects) and then insert then into what I think (pretty sure) is a Java program, is their anyway that this is possible in HTML or not? it has to be cilent side due to restrictions.I may add the Java program is running inside it's own window and cannot be integrated into the web page.If their is also a way to extract the information from the Java page on a click on a <button> and then file this into <input> boxes this could possible be looked into.Could someone please help point me in the right direction if this is possible or?Thanks Very Much =)Jny*Edit* (20:18) If their is also a way to extract the information from the Java page on a click on a <button> and then file this into <input> boxes this could possible be looked into.
  13. Okay I'm having problems reading data from a port (COM3)I'm running a program VirtualGPS to emulate a GPS receiver unit which is running on COM3now what I'm trying to do is read this data in and save it locally to my database. although at the moment i'm just trying to print the data out to screen.I'm receiving these error messages:Warning: Specified serial port is not valid in C:\Users\Jonathon\Desktop\XAMPP\htdocs\CentraFuse\php_serial.class.php on line 111Warning: The device must be set before to be open in C:\Users\Jonathon\Desktop\XAMPP\htdocs\CentraFuse\php_serial.class.php on line 137Warning: Device must be opened in C:\Users\Jonathon\Desktop\XAMPP\htdocs\CentraFuse\php_serial.class.php on line 541Warning: Device must be opened to read it in C:\Users\Jonathon\Desktop\XAMPP\htdocs\CentraFuse\php_serial.class.php on line 474Warning: Unable to set the baud rate : the device is either not set or opened in C:\Users\Jonathon\Desktop\XAMPP\htdocs\CentraFuse\php_serial.class.php on line 204which would imply the serial port is not in use right? so i change the port to use COM5 (used for bluetooth connection from phone and laptop) changed the settings and ran it again which the same problem.)Here are two codes I'm using <?phpdefine ("SERIAL_DEVICE_NOTSET", 0);define ("SERIAL_DEVICE_SET", 1);define ("SERIAL_DEVICE_OPENED", 2);/** * Serial port control class * * THIS PROGRAM COMES WITH ABSOLUTELY NO WARANTIES ! * USE IT AT YOUR OWN RISKS ! * * @author Rémy Sanchez <thenux@gmail.com> * @thanks Aurélien Derouineau for finding how to open serial ports with windows * @thanks Alec Avedisyan for help and testing with reading * @copyright under GPL 2 licence */class phpSerial{ var $_device = null; var $_windevice = null; var $_dHandle = null; var $_dState = SERIAL_DEVICE_NOTSET; var $_buffer = ""; var $_os = ""; /** * This var says if buffer should be flushed by sendMessage (true) or manualy (false) * * @var bool */ var $autoflush = true; /** * Constructor. Perform some checks about the OS and setserial * * @return phpSerial */ function phpSerial () { setlocale(LC_ALL, "en_US"); $sysname = php_uname(); if (substr($sysname, 0, 5) === "Linux") { $this->_os = "linux"; if($this->_exec("stty --version") === 0) { register_shutdown_function(array($this, "deviceClose")); } else { trigger_error("No stty availible, unable to run.", E_USER_ERROR); } } elseif(substr($sysname, 0, 7) === "Windows") { $this->_os = "windows"; register_shutdown_function(array($this, "deviceClose")); } else { trigger_error("Host OS is neither linux nor windows, unable tu run.", E_USER_ERROR); exit(); } } // // OPEN/CLOSE DEVICE SECTION -- {START} // /** * Device set function : used to set the device name/address. * -> linux : use the device address, like /dev/ttyS0 * -> windows : use the COMxx device name, like COM1 (can also be used * with linux) * * @param string $device the name of the device to be used * @return bool */ function deviceSet ($device) { if ($this->_dState !== SERIAL_DEVICE_OPENED) { if ($this->_os === "linux") { if (preg_match("@^COM(\d+):?$@i", $device, $matches)) { $device = "/dev/ttyS" . ($matches[1] - 1); } if ($this->_exec("stty -F " . $device) === 0) { $this->_device = $device; $this->_dState = SERIAL_DEVICE_SET; return true; } } elseif ($this->_os === "windows") { if (preg_match("@^COM(\d+):?$@i", $device, $matches) and $this->_exec(exec("mode " . $device)) === 0) { $this->_windevice = "COM" . $matches[1]; $this->_device = "\\.\com" . $matches[1]; $this->_dState = SERIAL_DEVICE_SET; return true; } } trigger_error("Specified serial port is not valid", E_USER_WARNING); return false; } else { trigger_error("You must close your device before to set an other one", E_USER_WARNING); return false; } } /** * Opens the device for reading and/or writing. * * @param string $mode Opening mode : same parameter as fopen() * @return bool */ function deviceOpen ($mode = "r+b") { if ($this->_dState === SERIAL_DEVICE_OPENED) { trigger_error("The device is already opened", E_USER_NOTICE); return true; } if ($this->_dState === SERIAL_DEVICE_NOTSET) { trigger_error("The device must be set before to be open", E_USER_WARNING); return false; } if (!preg_match("@^[raw]\+?b?$@", $mode)) { trigger_error("Invalid opening mode : ".$mode.". Use fopen() modes.", E_USER_WARNING); return false; } $this->_dHandle = @fopen($this->_device, $mode); if ($this->_dHandle !== false) { stream_set_blocking($this->_dHandle, 0); $this->_dState = SERIAL_DEVICE_OPENED; return true; } $this->_dHandle = null; trigger_error("Unable to open the device", E_USER_WARNING); return false; } /** * Closes the device * * @return bool */ function deviceClose () { if ($this->_dState !== SERIAL_DEVICE_OPENED) { return true; } if (fclose($this->_dHandle)) { $this->_dHandle = null; $this->_dState = SERIAL_DEVICE_SET; return true; } trigger_error("Unable to close the device", E_USER_ERROR); return false; } // // OPEN/CLOSE DEVICE SECTION -- {STOP} // // // CONFIGURE SECTION -- {START} // /** * Configure the Baud Rate * Possible rates : 110, 150, 300, 600, 1200, 2400, 4800, 9600, 38400, * 57600 and 115200. * * @param int $rate the rate to set the port in * @return bool */ function confBaudRate ($rate) { if ($this->_dState !== SERIAL_DEVICE_SET) { trigger_error("Unable to set the baud rate : the device is either not set or opened", E_USER_WARNING); return false; } $validBauds = array ( 110 => 11, 150 => 15, 300 => 30, 600 => 60, 1200 => 12, 2400 => 24, 4800 => 48, 9600 => 96, 19200 => 19, 38400 => 38400, 57600 => 57600, 115200 => 115200 ); if (isset($validBauds[$rate])) { if ($this->_os === "linux") { $ret = $this->_exec("stty -F " . $this->_device . " " . (int) $rate, $out); } elseif ($this->_os === "windows") { $ret = $this->_exec("mode " . $this->_windevice . " BAUD=" . $validBauds[$rate], $out); } else return false; if ($ret !== 0) { trigger_error ("Unable to set baud rate: " . $out[1], E_USER_WARNING); return false; } } } /** * Configure parity. * Modes : odd, even, none * * @param string $parity one of the modes * @return bool */ function confParity ($parity) { if ($this->_dState !== SERIAL_DEVICE_SET) { trigger_error("Unable to set parity : the device is either not set or opened", E_USER_WARNING); return false; } $args = array( "none" => "-parenb", "odd" => "parenb parodd", "even" => "parenb -parodd", ); if (!isset($args[$parity])) { trigger_error("Parity mode not supported", E_USER_WARNING); return false; } if ($this->_os === "linux") { $ret = $this->_exec("stty -F " . $this->_device . " " . $args[$parity], $out); } else { $ret = $this->_exec("mode " . $this->_windevice . " PARITY=" . $parity{0}, $out); } if ($ret === 0) { return true; } trigger_error("Unable to set parity : " . $out[1], E_USER_WARNING); return false; } /** * Sets the length of a character. * * @param int $int length of a character (5 <= length <= 8) * @return bool */ function confCharacterLength ($int) { if ($this->_dState !== SERIAL_DEVICE_SET) { trigger_error("Unable to set length of a character : the device is either not set or opened", E_USER_WARNING); return false; } $int = (int) $int; if ($int < 5) $int = 5; elseif ($int > 8) $int = 8; if ($this->_os === "linux") { $ret = $this->_exec("stty -F " . $this->_device . " cs" . $int, $out); } else { $ret = $this->_exec("mode " . $this->_windevice . " DATA=" . $int, $out); } if ($ret === 0) { return true; } trigger_error("Unable to set character length : " .$out[1], E_USER_WARNING); return false; } /** * Sets the length of stop bits. * * @param float $length the length of a stop bit. It must be either 1, * 1.5 or 2. 1.5 is not supported under linux and on some computers. * @return bool */ function confStopBits ($length) { if ($this->_dState !== SERIAL_DEVICE_SET) { trigger_error("Unable to set the length of a stop bit : the device is either not set or opened", E_USER_WARNING); return false; } if ($length != 1 and $length != 2 and $length != 1.5 and !($length == 1.5 and $this->_os === "linux")) { trigger_error("Specified stop bit length is invalid", E_USER_WARNING); return false; } if ($this->_os === "linux") { $ret = $this->_exec("stty -F " . $this->_device . " " . (($length == 1) ? "-" : "") . "cstopb", $out); } else { $ret = $this->_exec("mode " . $this->_windevice . " STOP=" . $length, $out); } if ($ret === 0) { return true; } trigger_error("Unable to set stop bit length : " . $out[1], E_USER_WARNING); return false; } /** * Configures the flow control * * @param string $mode Set the flow control mode. Availible modes : * -> "none" : no flow control * -> "rts/cts" : use RTS/CTS handshaking * -> "xon/xoff" : use XON/XOFF protocol * @return bool */ function confFlowControl ($mode) { if ($this->_dState !== SERIAL_DEVICE_SET) { trigger_error("Unable to set flow control mode : the device is either not set or opened", E_USER_WARNING); return false; } $linuxModes = array( "none" => "clocal -crtscts -ixon -ixoff", "rts/cts" => "-clocal crtscts -ixon -ixoff", "xon/xoff" => "-clocal -crtscts ixon ixoff" ); $windowsModes = array( "none" => "xon=off octs=off rts=on", "rts/cts" => "xon=off octs=on rts=hs", "xon/xoff" => "xon=on octs=off rts=on", ); if ($mode !== "none" and $mode !== "rts/cts" and $mode !== "xon/xoff") { trigger_error("Invalid flow control mode specified", E_USER_ERROR); return false; } if ($this->_os === "linux") $ret = $this->_exec("stty -F " . $this->_device . " " . $linuxModes[$mode], $out); else $ret = $this->_exec("mode " . $this->_windevice . " " . $windowsModes[$mode], $out); if ($ret === 0) return true; else { trigger_error("Unable to set flow control : " . $out[1], E_USER_ERROR); return false; } } /** * Sets a setserial parameter (cf man setserial) * NO MORE USEFUL ! * -> No longer supported * -> Only use it if you need it * * @param string $param parameter name * @param string $arg parameter value * @return bool */ function setSetserialFlag ($param, $arg = "") { if (!$this->_ckOpened()) return false; $return = exec ("setserial " . $this->_device . " " . $param . " " . $arg . " 2>&1"); if ($return{0} === "I") { trigger_error("setserial: Invalid flag", E_USER_WARNING); return false; } elseif ($return{0} === "/") { trigger_error("setserial: Error with device file", E_USER_WARNING); return false; } else { return true; } } // // CONFIGURE SECTION -- {STOP} // // // I/O SECTION -- {START} // /** * Sends a string to the device * * @param string $str string to be sent to the device * @param float $waitForReply time to wait for the reply (in seconds) */ function sendMessage ($str, $waitForReply = 0.1) { $this->_buffer .= $str; if ($this->autoflush === true) $this->flush(); usleep((int) ($waitForReply * 1000000)); } /** * Reads the port until no new datas are availible, then return the content. * * @pararm int $count number of characters to be read (will stop before * if less characters are in the buffer) * @return string */ function readPort ($count = 0) { if ($this->_dState !== SERIAL_DEVICE_OPENED) { trigger_error("Device must be opened to read it", E_USER_WARNING); return false; } if ($this->_os === "linux") { $content = ""; $i = 0; if ($count !== 0) { do { if ($i > $count) $content .= fread($this->_dHandle, ($count - $i)); else $content .= fread($this->_dHandle, 128); } while (($i += 128) === strlen($content)); } else { do { $content .= fread($this->_dHandle, 128); } while (($i += 128) === strlen($content)); } return $content; } elseif ($this->_os === "windows") { /* Do nothing : not implented yet */ } trigger_error("Reading serial port is not implemented for Windows", E_USER_WARNING); return false; } /** * Flushes the output buffer * * @return bool */ function flush () { if (!$this->_ckOpened()) return false; if (fwrite($this->_dHandle, $this->_buffer) !== false) { $this->_buffer = ""; return true; } else { $this->_buffer = ""; trigger_error("Error while sending message", E_USER_WARNING); return false; } } // // I/O SECTION -- {STOP} // // // INTERNAL TOOLKIT -- {START} // function _ckOpened() { if ($this->_dState !== SERIAL_DEVICE_OPENED) { trigger_error("Device must be opened", E_USER_WARNING); return false; } return true; } function _ckClosed() { if ($this->_dState !== SERIAL_DEVICE_CLOSED) { trigger_error("Device must be closed", E_USER_WARNING); return false; } return true; } function _exec($cmd, &$out = null) { $desc = array( 1 => array("pipe", "w"), 2 => array("pipe", "w") ); $proc = proc_open($cmd, $desc, $pipes); $ret = stream_get_contents($pipes[1]); $err = stream_get_contents($pipes[2]); fclose($pipes[1]); fclose($pipes[2]); $retVal = proc_close($proc); if (func_num_args() == 2) $out = array($ret, $err); return $retVal; } // // INTERNAL TOOLKIT -- {STOP} //}?> and <?php include "php_serial.class.php"; // Let's start the class $serial = new phpSerial; // First we must specify the device. This works on both linux and windows (if // your linux serial device is /dev/ttyS0 for COM1, etc) $serial->deviceSet("COM3"); // Then we need to open it $serial->deviceOpen(); // To write into $serial->sendMessage("Hello !"); // Or to read from $read = $serial->readPort(); // If you want to change the configuration, the device must be closed $serial->deviceClose(); // We can change the baud rate $serial->confBaudRate(96000); // etc... echo $read;?> anyone have any ideas?I am running Windows Vista if their is also any way i can run this script without having to open a browser but from start up that would be perfect as well.
  14. Okay i have four variables$team1, $team2, $team3, $team4i'm trying to see which team has be biggest number so at the moment i'm using this code. <?phprequire("Connections/request.php");set_time_limit(0); //Run Drag Racesmysql_select_db($database_request,$request);$get=mysql_query("SELECT * FROM `league_drag` WHERE `RaceNo`=0");while($show=mysql_fetch_object($get)){ //Do Team 1 $team=mysql_fetch_object(mysql_query("SELECT * FROM `teams` WHERE `id`='$show->t1id'"));echo mysql_error(); $engine=mysql_fetch_object(mysql_query("SELECT * FROM `company_engine` WHERE `id`='$team->eid'"));echo mysql_error(); $tyre=mysql_fetch_object(mysql_query("SELECT * FROM `company_tyres` WHERE `id`='$team->wid'"));echo mysql_error(); $brake=mysql_fetch_object(mysql_query("SELECT * FROM `company_brakes` WHERE `id`='$team->bid'"));echo mysql_error(); if($engine->reliability>=rand(0,100) { //Engine Okay $testVal= if($tyre->reliability>=rand(0,100) { //Engine Okay $carSpec=(($tyre->grip/100)*25)+(($engine->bhp/100)*75); $driver=mysql_fetch_object(mysql_query("SELECT * FROM `drivers` WHERE `id`='$team->d1id'")); $driSpec=($driver->acceleration+$driver->control)/2; $team1=$carSpec+$driSpec; } else { $mailMsg1="Tyre Popped"; $team1=0; } } else { $mailMsg1="Engine Blew Up"; $team1=0; } if(isset($mailMsg1)) mysql_query("INSERT INTO `user_messages` (`to_u`,`title`,`info`) VALUES ('$team->pid','Important Race Message','$mailMsg1')"); //Do Team 2 $team=mysql_fetch_object(mysql_query("SELECT * FROM `teams` WHERE `id`='$show->t2id'")); $engine=mysql_fetch_object(mysql_query("SELECT * FROM `company_engine` WHERE `id`='$team->eid'")); $tyre=mysql_fetch_object(mysql_query("SELECT * FROM `company_tyres` WHERE `id`='$team->wid'")); $brake=mysql_fetch_object(mysql_query("SELECT * FROM `company_brakes` WHERE `id`='$team->bid'")); if($engine->reliability>=rand(0,100)) { //Engine Okay if($tyre->reliability>=rand(0,100)) { //Engine Okay $carSpec=(($tyre->grip/100)*25)+(($engine->bhp/100)*75); $driver=mysql_fetch_object(mysql_query("SELECT * FROM `drivers` WHERE `id`='$team->d1id'")); $driSpec=($driver->acceleration+$driver->control)/2; $team2=$carSpec+$driSpec; } else { $mailMsg2="Tyre Popped"; $team2=0; } } else { $mailMsg2="Engine Blew Up"; $team2=0; } if(isset($mailMsg2)) mysql_query("INSERT INTO `user_messages` (`to_u`,`title`,`info`) VALUES ('$team->pid','Important Race Message','$mailMsg2')"); //Do Team 3 $team=mysql_fetch_object(mysql_query("SELECT * FROM `teams` WHERE `id`='$show->t3id'")); $engine=mysql_fetch_object(mysql_query("SELECT * FROM `company_engine` WHERE `id`='$team->eid'")); $tyre=mysql_fetch_object(mysql_query("SELECT * FROM `company_tyres` WHERE `id`='$team->wid'")); $brake=mysql_fetch_object(mysql_query("SELECT * FROM `company_brakes` WHERE `id`='$team->bid'")); if($engine->reliability>=rand(0,100)) { //Engine Okay if($tyre->reliability>=rand(0,100)) { //Engine Okay $carSpec=(($tyre->grip/100)*25)+(($engine->bhp/100)*75); $driver=mysql_fetch_object(mysql_query("SELECT * FROM `drivers` WHERE `id`='$team->d1id'")); $driSpec=($driver->acceleration+$driver->control)/2; $team3=$carSpec+$driSpec; } else { $mailMsg3="Tyre Popped"; $team3=0; } } else { $mailMsg3="Engine Blew Up"; $team3=0; } if(isset($mailMsg3)) mysql_query("INSERT INTO `user_messages` (`to_u`,`title`,`info`) VALUES ('$team->pid','Important Race Message','$mailMsg3')"); //Do Team 4 $team=mysql_fetch_object(mysql_query("SELECT * FROM `teams` WHERE `id`='$show->t4id'")); $engine=mysql_fetch_object(mysql_query("SELECT * FROM `company_engine` WHERE `id`='$team->eid'")); $tyre=mysql_fetch_object(mysql_query("SELECT * FROM `company_tyres` WHERE `id`='$team->wid'")); $brake=mysql_fetch_object(mysql_query("SELECT * FROM `company_brakes` WHERE `id`='$team->bid'")); if($engine->reliability>=rand(0,100)) { //Engine Okay if($tyre->reliability>=rand(0,100)) { //Engine Okay $carSpec=(($tyre->grip/100)*25)+(($engine->bhp/100)*75); $driver=mysql_fetch_object(mysql_query("SELECT * FROM `drivers` WHERE `id`='$team->d1id'")); $driSpec=($driver->acceleration+$driver->control)/2; $team4=$carSpec+$driSpec; } else { $mailMsg4="Tyre Popped"; $team4=0; } } else { $mailMsg4="Engine Blew Up"; $team4=0; } if(isset($mailMsg4)) mysql_query("INSERT INTO `user_messages` (`to_u`,`title`,`info`) VALUES ('$team->pid','Important Race Message','$mailMsg4')"); //Print Out Each Teams Variables echo '<br />Team1:'.$team1; if(isset($mailMsg1)) echo '<strong>'.$mailMsg1.'</strong>'; echo '<br />Team2:'.$team2; if(isset($mailMsg2)) echo '<strong>'.$mailMsg2.'</strong>'; echo '<br />Team3:'.$team3; if(isset($mailMsg3)) echo '<strong>'.$mailMsg3.'</strong>'; echo '<br />Team4:'.$team4; if(isset($mailMsg4)) echo '<strong>'.$mailMsg4.'</strong>'; echo '<br />'; $myarray = array($team1,$team2,$team3,$team4); sort($myarray); print_r($myarray); //Finished First echo'<br />'; if($myarray[3]==$team4) echo 'Team 4 Wins'; else if($myarray[3]==$team3) echo 'Team 3 Wins'; else if($myarray[3]==$team2) echo 'Team 2 Wins'; else if($myarray[3]==$team1) echo 'Team 1 Wins'; echo'<br />';//Finshed Second if($myarray[2]==$team4) echo 'Team 4 Second'; else if($myarray[2]==$team3) echo 'Team 3 Second'; else if($myarray[2]==$team2) echo 'Team 2 Second'; else if($myarray[2]==$team1) echo 'Team 1 Second'; echo'<br />';//Finshed Third if($myarray[1]==$team1) echo 'Team 1 Third'; else if($myarray[1]==$team2) echo 'Team 2 Third'; else if($myarray[1]==$team3) echo 'Team 3 Third'; else if($myarray[1]==$team4) echo 'Team 4 Third'; echo'<br />';//Finshed Fourth if($myarray[0]==$team4) echo 'Team 4 Last'; else if($myarray[0]==$team3) echo 'Team 3 Last'; else if($myarray[0]==$team2) echo 'Team 2 Last'; else if($myarray[0]==$team1) echo 'Team 1 Last';}?>
  15. Thanks Guys, but i changed it to Joins as the area i was being marked on was about sub-selects i though i would have to do it as a subselect however i admitted defeat and done it all in a joinHere's the code i used incase anyone else is wonder and for future use SELECT concert.concert_venue, concert.con_date, composition.c_titleFROM concert, performance, composition, has_composed, composer, musicianWHERE concert_no = performed_inAND performed = composition.c_noAND composition.c_no = has_composed.cmpn_noAND cmpr_no = composer.comp_noAND composer.comp_is = musician.m_noAND m_name = 'Andy Jones'
  • Create New...