Jump to content

bsamson

Members
  • Posts

    150
  • Joined

  • Last visited

Everything posted by bsamson

  1. Hello. I am fairly new to cookies. I have basically 3 pages at this point. Login.php Validate.php front.php A user goes to the Login page and provides their credentials. The Validate page looks like this: <?php require_once("common.php"); // Loads ConnectTo Function $connection = ConnectTo("main"); $query = "SELECT * FROM employees WHERE uName='$_POST[uName]' AND pWord='$_POST[pWord]'"; $result = mysql_query($query); if (mysql_num_rows($result) == 0) { header("Location: http://mydomain.com/Login.php?err=1"); } else { while ($row=mysql_fetch_array($result)) { setcookie("sns_fname", $row['fname'], time()+3600); setcookie("sns_lname", $row['lname'], time()+3600); setcookie("sns_uName", $row['uName'], time()+3600); setcookie("sns_added", $row['added'], time()+3600); setcookie("sns_updated", $row['updated'], time()+3600); setcookie("sns_lastlogin", $row['lastlogin'], time()+3600); } header("Location: http://mydomain.com/front.php"); } ?> By the way, if i comment out the header line from Login.php, and put in this line: <?php echo $_COOKIE['sns_fname']; ?> It displays the name. if the username & password were found the user ends up @ front.php. Now, on front.php I try this: <?php echo $_COOKIE['sns_fname']; ?> And it doesn't display the name. Am i missing something obvious? Thanks in advance for any assistance!
  2. I don't know if it matters but the method I have opted for is a url like: index.php?id=help Then I created a script that I include in my template that looks like this: <?php // Check if first visit if ($_GET['id'] == "") { header("Location: http://www.mydomain.com/index.php?id=main"); } // Determine Tool to load $pg2Load = $_GET['id']; // Load Main Site Page $filename = '/home/nxsap/www/pg_'.$pg2Load.'.php'; if (file_exists($filename)) { $pgID = "pg_".$pg2Load.'.php'; } else { header("Location: http://www.mydomain.com/index.php?id=main"); } ?> With this method there is no need to include the PHP extention. Basically as your site grows you simply name the new page pg_PAGENAME.php and there is no need to worrying telling a script what the new page name is.
  3. Hey ALL! I know how to add days to the current date, <?php echo "15 Days from today is: ".date("m/d/Y", strtotime("+15 days"); ?> How do I calculate 15 days from today when the user inputs the date (i.e. Not today) example: 06/02/2008 + 15 days Thanks in advance!
  4. <?php $dateNow = date("Y/m/d H:i:s"); $dateThen = date("Y/m/d H:i:s", strtotime("+ 30 days")); ?>
  5. Hello. I am currently creating a security cam page for my company. Basically we have 21 stores all of which have IP based cams. I have seached and tried to find a function to accomblish this: check if cam is up and running and store the status in DB All the cam stills are accessed from a URL like: http://192.168.1.1:1024/img/mjpeg.jpg Of course it is a WAN IP for each store. In the above example I need a function that will ... Check to make sure it is accessable and account for page timeout if the image is unavailable. Basically I am creating a script that will run every 30 minutes to check if the cam is working and if not note the status accordingly. Thanks in advance for any help!!!
  6. Hello, I am not sure the best way to approach this, but here's the situation ... I have a table structured like so: STORE | DAY15 | DAY45 | DAY90 13 | 05/01/08 | 06/09/08 | 05/23/08 28 | 05/02/08 | 06/01/08 | 05/15/08 13 | 05/04/08 | 06/02/08 | 06/09/08 Now, obviously the actual table contains more data. What I am trying to do is create a mysql query that counts the number of of dates (ie. DAY15, DAY45, & DAY90 date fields) for all STORE numbers. In other words given the data above, I want these results: STORE 13 has 2 matching STORE 28 has 0 matching I hope I explained this well enough, but if not please let me know. Thanks in advance for any assistance!
  7. Is it possible to have too many WHERE, AND statements in one query? Example: SELECT * FROM v2followups WHERE store='11' AND (DATE_FORMAT(FROM_UNIXTIME(`day15`), '%Y/%m/%d') = '2008/05/16' AND day15status != 'c') OR (DATE_FORMAT(FROM_UNIXTIME(`day45`), '%Y/%m/%d') = '2008/05/16' AND day45status != 'c') OR (DATE_FORMAT(FROM_UNIXTIME(`day90`), '%Y/%m/%d') = '2008/05/16' AND day90status != 'c') AND cbtype='f' (The above query was ran in phpMyAdmin) All seems to work EXCEPT it also returns entries where cbtype='c'. Any suggestions as to why this isn't working? Thanks in advance!
  8. Hello! I have a situation and I am struggling with how to achieve this .... I maintain an internal site for the company I work for. There are 21 stores who use it daily to lookup contact info and submit company reports. All is working well. However, I am now in process of creating a new report and am having an issue with how to set it up. Basically the process is: A new customer signs up for new service (cell phone service.) After new service is established the employee has to call the customer back in 15days, 45days, and 90days to address any concerns. The employee visits the customer followup page where they enter basic customer info and submit the info. I have already figured out how to generate the callback dates (taking into consideration no calls on sundays) The current DB Tables stores the entrydate (in unix time) Now, the situation .... Should I create 3 fields (day15date, day45date, day90date) and store the callback dates, OR should I generate the callback dates based on entry date? If I go w/ option B, I would also create fields (day15status, day45status, day90status) that I would reference with a single letter (N-NEW, R-Reschuled, and C-Complete). I have been pondering this situation for a week now and cannot seem to be able to come up with an efficient solution. The whole reason for this report is to remind the employee when to call the customer. Of course taking into consideration if they fail to call them back on the due date to move it to the next day. I was thinking a cron job to achive that. Anyway, thanks in advance for any suggestions!
  9. *bump* No suggestions? I have googled and search and cannot figure this one out...
  10. Thanks for the input. But it doesn't appear to be working. Via phpMyAdmin I am running this query: SELECT * from v2callbacks WHERE DATE_ADD(DATE_FORMAT(FROM_UNIXTIME(`entrydate`), '%m/%d/%Y'), INTERVAL 15 DAY) = '05/28/2008' I have a field that I set the entrydate to: 1211995559 (which is 05/28/2008) However, phpMyAdmin reports: MySQL returned an empty result set (i.e. zero rows). (Query took 0.0004 sec) Any suggestions?
  11. hmmm ... when I run the following query ... it doesn't appear to error out. Any pros and/or cons? <?php mysql_query("SELECT * from v2callbacks WHERE DATE_ADD(DATE_FORMAT(FROM_UNIXTIME(`entrydate`), '%Y/%m/%d'), INTERVAL 15 DAY) = '2008/05/13'"); ?> Thanks again...
  12. Alright I currently have this code: <?php mysql_query("SELECT * FROM v2callbacks WHERE DATE_FORMAT(FROM_UNIXTIME(`entrydate`), '%Y/%m/%d') = '2008/05/13'") ?> How do I change this section: DATE_FORMAT(FROM_UNIXTIME(`entrydate`), '%Y/%m/%d') to add 15 days to the entrydate field? Not change the field BUT take the entrydate and add 15 days. Thanks in advance!
  13. I am sure I am missing something here but I have this script: <?php $today = date("Y/m/d"); $unixtime = date("U"); // connection information $db2con = "reports"; include "../dbConnect.php"; $query = mysql_query("SELECT * FROM v2breakdown WHERE DATE_FORMAT(FROM_UNIXTIME(`entrydate`), '%Y/%m/%d') = '$today'") or die(mysql_error()); // connection information $db2con = "stats"; include "../dbConnect.php"; while ($row = mysql_fetch_assoc($query)) { mysql_query("INSERT INTO v2ActsMTD (gendate, store, region, spnew, sp12, sp22, nxnew, nx12, nx22) VALUES ('$unixtime', '$row[store]', '$row[region]', '$_POST[spNew]', '$_POST[sp12Mo]', '$_POST[sp22Mo]', '$_POST[nxNew]', '$_POST[nx12Mo]', '$_POST[nx22Mo]')") or die(mysql_error()); } ?> Contents of dbConnect.php <?php $hostName = "localhost"; $dbName = "nnyserve_".$db2con; $userName = "nnyserve_username"; $password = "password"; mysql_connect($hostName, $userName, $password) or die("Unable to connect to host $hostName"); mysql_select_db($dbName) or die( "Unable to select database $dbName"); ?> Everytime I run this script I get this error: Unable to select database nnyserve_stats The dbConnect.php script simply makes the connection and $db2con is the name of the DB. I have confirmed that stats exists and can't seem to figure out what causing this. Any suggestions would be greatly appreciated!
  14. I wasn't sure how to word the subject ... but here's what I am trying to do. I have a mysql table that looks something like this: StoreNumber | Date | Score1 | Score2 | Score3 Now, as an example I have this in this table ... 01 | 05/09/2008 | 50 | 20 | 30 04 | 05/06/2008 | 28 | 12 | 45 07 | 05/01/2008 | 85 | 43 | 76 04 | 05/04/2008 | 21 | 11 | 18 07 | 05/09/2008 | 54 | 78 | 10 02 | 05/02/2008 | 12 | 43 | 30 Now, let's say I run this query: SELECT SUM(score1)+SUM(score2)+SUM(score3) as totalscore FROM v2breakdown WHERE DATE_FORMAT(FROM_UNIXTIME(`entrydate`), '%Y/%m/%d') >= '2008/05/01' ORDER BY totalscore ASC Obviously one of the things I know is the results will be listed low to high which in turn will reveal where that location ranks. I am just trying to determine where a location ranks company wide. The above query will list them in order but outside of an if..then statement is there something I can add to the query that will tell me the store's rank? Thanks in adance!
  15. Thanks for all the help so far! I was curious though. Why didn't my original example work? Thanks in advance.
  16. Wow! I just have one more question. Oppose to echoing the results how would I go about storing the info in an array? Thanks for your help!
  17. Hello. I have the following script: <?php $depinfo = "01~01~111,02~02~222,03~03~333"; $depdays = explode(",", $depinfo); $nodays = count($depdays); for ($a=0; $a <= ($nodays-2); $a++) { $dayinfo = explode("~", $depdays[$a]); $depmo[$a] = $dayinfo[$a]; $depdy[$a] = $dayinfo[$a+1]; $depam[$a] = $dayinfo[$a+2]; echo $depmo[$a]."-".$depdy[$a]."-".$depam[$a]."<br>"; } ?> The output I am trying to achieve is: 01-01-111 02-02-222 03-03-333 The output I am getting is: 01-01-111 02-222- Can I please just get an idea where I am going wrong? Thanks in advance!
  18. Anyone have any other suggestions? Thanks in advance! Best Regards, Brian
  19. Ok ... Just tried your scripts ... and now this: Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in /home/nnyserve/public_html/backend/cams/scripts/imgTest.php on line 4 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: 'grabStill-3.php' is not a valid JPEG file in /home/nnyserve/public_html/backend/cams/scripts/imgTest.php on line 4 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /home/nnyserve/public_html/backend/cams/scripts/imgTest.php on line 5 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/nnyserve/public_html/backend/cams/scripts/imgTest.php on line 6 Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/nnyserve/public_html/backend/cams/scripts/imgTest.php on line 9 Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/nnyserve/public_html/backend/cams/scripts/imgTest.php on line 10 I just dont understand PHP & images ... lol ... thanks for all your help though! Any other suggestions?? Thanks! Best Regards, Brian
  20. Ok ... using this script: <?php $camurl="http://111.111.111.111:1024/img/video.mjpeg"; $boundary="\n--"; $f = fopen($camurl,"r"); //**** URL OK // Transfer the image... while (substr_count($r,"Content-Length") != 2) $r.=fread($f,512); $start = strpos($r,'ÿ'); $end = strpos($r,$boundary,$start)-1; $frame = substr("$r",$start,$end - $start); $size = getimagesize($frame); $img_src = imagecreatefromjpeg($frame); $img_dst=imagecreatetruecolor($size[0],$size[1]); imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $size[0], $size[1], $size[0], $size[1]); $folder = "/home/nnyserve/www/backend/cams/scripts/stills/"; $filename = "somename.jpg"; imagejpeg($img_dst, $folder.$filename); imagedestroy($img_dst); // header("Content-type: image/jpeg"); // echo $frame; fclose($f); ?> I received these errors: Warning: getimagesize(ÿØÿÛ) [function.getimagesize]: failed to open stream: No such file or directory in /home/nnyserve/public_html/backend/cams/scripts/grabStill-4.php on line 17 Warning: imagecreatefromjpeg(ÿØÿÛ) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory in /home/nnyserve/public_html/backend/cams/scripts/grabStill-4.php on line 18 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /home/nnyserve/public_html/backend/cams/scripts/grabStill-4.php on line 19 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/nnyserve/public_html/backend/cams/scripts/grabStill-4.php on line 20 Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/nnyserve/public_html/backend/cams/scripts/grabStill-4.php on line 23 Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/nnyserve/public_html/backend/cams/scripts/grabStill-4.php on line 24 LOL ... Thanks for all the help thus far Craygo ... but any other idea's? Best regards, Brian Samson
  21. I just copied the script to my personal domain. Here is the URL: http://www.nnylocal.com/phpFreaks/grabStill-3.php. This is a working cam in one of our stores ... Thanks! Best Regards, Brian Samson
×
×
  • 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.