Jump to content

MadTechie

Staff Alumni
  • Posts

    9,409
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by MadTechie

  1. Okay let me see if i can create a live example
  2. okay less control but try a good old webscrape $key = "THE KEY FOR YOUR SPREADSHEET"; $url = "http://spreadsheets.google.com/feeds/cells/$key/1/public/values"; $ch = curl_init (); // set URL and other appropriate options curl_setopt ( $ch, CURLOPT_URL, $url ); curl_setopt ( $ch, CURLOPT_HEADER, 0 ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, TRUE ); // grab URL and pass it to the browser $google_sheet = curl_exec ( $ch ); // close cURL resource, and free up system resources curl_close ( $ch ); $doc = new DOMDocument ( ); $doc->loadXML ( $google_sheet ); $nodes = $doc->getElementsByTagName ( "cell" ); if ($nodes->length > 0) { foreach ( $nodes as $node ) { // 2nd row if ($node->getAttribute ( "row" ) == 2){ if (preg_match('/^[.+_a-z0-9-]+@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$/', $node->nodeValue)) { echo $node->nodeValue; } } } }
  3. Solved ? if so please "Mark Solved" bottom left
  4. Maybe reading Google Spreadsheets APIs (Developer's Guide: PHP) would be a good place to start! basically you use Zend Framework and use the class Zend_Gdata_Spreadsheets_CellQuery ie public function cellsGetAction(){ $query = new Zend_Gdata_Spreadsheets_CellQuery(); $query->setSpreadsheetKey($this->currKey); $query->setWorksheetId($this->currWkshtId); $feed = $this->gdClient->getCellFeed($query); $this->printFeed($feed); }
  5. I am not going to write the code for you, but I'm happy to help get you started, First of all you need to create the database and table, Lets say you have a table called birthdays with 56 fields ID, FirstName, LastName, ClassYear, DOB, tempDOB ID = medium INT FirstName, LastName, ClassYear & tempDOB= VarChar(50) DOB = DATE First we need to import your data into the table, this depends on the format you have so i suggest getting it into excel (or something) and saving as a CSV file, frmo that you can create an importer or find one (theirs tons) you could use phpmyadmin, if you wish to list the data and edit the data online then we can work on that later.. okay now import the date of birth into `tempDOB` and NOT `DOB`, the reason for this is, because while "01 February 2010" looks nice its not so nice when coding with, so we need to convert the pretty text into some useful data, to show an example try this date_default_timezone_set('Europe/London'); $date = "01 February 2010"; $phptime = strtotime($date); echo "$phptime = ".date("d F Y",$phptime); result (something like) alot of work for no real gain you maybe thinking.. well when searching for a date or sorting by date it proves very useful.. So a quick little script to update the DOB field //Update DOB date_default_timezone_set('Europe/London'); $SQLSelect = "SELECT ID, DOBTemp from birthdays"; $result = mysql_query($SQLSelect) or die($SQLSelect."\n".mysql_error()); while($row = mysql_fetch_assoc($result)){ $SQLUpdate = sprintf("UPDATE birthdays SET DOB = %d WHERE ID = %d",strtotime($row['DOBTemp']),$row['ID']); mysql_query($SQLUpdate) or die($SQLUpdate."\n".mysql_error()); } You could probably do this directly from MySQL like this, UPDATE birthdays SET DOB = STR_TO_DATE(`DOBTemp`,"%d %M %Y"); Now view the data in PHPMyAdmin to check its all fine when you sure you could drop the DOBTemp field (if you want to save space, but keep it until your sure) Now to show thw birthdays a simple script should do it //Show Birthday date_default_timezone_set('Europe/London'); $SQLSelect = "SELECT *, YEAR(NOW())-YEAR(DOB) as Age from birthdays WHERE DAYOFYEAR(DOB) = DAYOFYEAR(NOW())"; $result = mysql_query($SQLSelect) or die($SQLSelect."\n".mysql_error()); echo "Happy Birthday (plz beat the hell out of)<BR />\n"; while($row = mysql_fetch_assoc($result)){ echo $row['FirstName']." ".$row['LastName']." - ".$row['ClassYear']." is ".$row['Age']." today<BR />\n"; } Note that , YEAR(NOW())-YEAR(DOB) as Age works out the persons age. Okay, i haven't proof read or tested the above, but should get you started
  6. You would think so.. Could be because i connected remotely.. from a PC with a poop display.. who knows I'll check when I get home.
  7. I heard early 2011, Only a ATI Radeon 5750 (I'm not really a gamer) Details- Name ATI Radeon HD 5700 Series Adapter Type ATI display adapter (0x68B8), ATI Technologies Inc. compatible Adapter Description ATI Radeon HD 5700 Series Adapter RAM 1.00 GB (1,073,741,824 bytes) Installed Drivers atiumd64.dll,atidxx64.dll,atidxx64.dll,atiumdag,atidxx32,atidxx32,atiumdva,atiumd6a.cap,atitmm64.dll Driver Version 8.681.0.0 INF File oem13.inf (ati2mtag_Evergreen section) Color Table Entries 4294967296 Resolution 1680 x 1050 x 60 hertz Bits/Pixel 32 Driver c:\windows\system32\drivers\atikmdag.sys (8.1.1.984, 5.89 MB (6,174,720 bytes), 22/01/2010 12:20) I'll check when i get home (I dislike working on my PC remotely)
  8. You know Windows did complain about the memory running low and switched from Aero to basic.. funny thing is i had 6Gb or memory left and CPU was only at 15%, I guess I'll double check my drivers etc
  9. Can you use a sub domain or worst case use a thiry party cookie
  10. See my last post (in your other thread) about you not handling arrays correctly..
  11. Yes, because you passing an array and probably not handlering it correctly.. Creating two posts and a little details in each will make our lifes hard and will reduce your change of getting quicker help
  12. Would need to see the debug data, (echo some variables to check the data) but $query = "SELECT * FROM textnook WHERE phonenumber = '{$_POST['phonenumber']}'"; iassume it should be this $query = "SELECT * FROM textnook WHERE phonenumber = '$phonenumber'"; its probably not much of a change but i don't see $_POST used anywhere or $phonenumber being set for that matter.. oh and you may want to read up on SQL injections EDIT: STOP creating multiple threads technically once one of them is solved you be able to workout the rest, but you have make it much harder to help you... Read up on using arrays and it will solve your problem, also try some debugging! (echo some variables!)
  13. a sub domains/same IP or differen FQDN ? for security reasons, your browser won’t let you read other domain’s cookies, only work around would be a third-party cookie, for sub domains see setcookie setcookie(Name,Value,Expire,Path,domain)
  14. My PC seams to run well with Windows 7 Pro, had a few access rights problems but that was easy to fix, I haven't moved to a trible boot yet, will post some results comparing the systems, (I'll need to get a copy of XP Pro (64 bit) to make it fair), and i guess I could use a Live CD, I guess I'll have to make up some tests System Spec OS Name: Microsoft Windows 7 Professional System Type: x64-based PC Processor: Intel® Core i7 CPU 950 @ 3.07GHz, 3068 Mhz, 4 Core(s), 8 Logical Processor(s) Hardware Abstraction Layer Version: "6.1.7600.16385" Installed Physical Memory (RAM): 12.0 GB
  15. Well a fuller picture is needed.. what do you have access to, whats the current process and what would you like to have happen ?
  16. Sure, lets create some examples, Here is a simple if statement inside some HTML (inline coding) some HTML<BR /> <?php if(11 > 10){ echo "11 is greater than 10<BR />"; }else{ echo "11 is NOT greater than 10<BR />"; } ?> More HTML output is Now instead of using echo you could just close the PHP tags ie some HTML<BR /> <?php if(11 > 10){ ?> 11 is greater than 10<BR /> <?php }else{ ?> 11 is NOT greater than 10<BR /> <?php } ?> More HTML and we get the same result Now echo require one or more parameters so echo "one"; //one echo "two","three"; // twothree echo "4","5","6"; // 456 echo ; //Failed Parse error: syntax error, unexpected ';' Now lets look at your error, } else { echo ?> onclick="MM_goToURL('parent','../index_fab10.php?ItemCode=<?php echo $row_rs_item1['ItemCode'];?>&pagenum= translates to } else { echo ;echo $row_rs_item1['ItemCode']; when you remove the HTML code Now i know you maybe thinking where did that extra semi-colon come from.. surely it should be echo echo $row_rs_item1['ItemCode']; and get a different error Well when you close a PHP tags ?>, it will close the last line for you for example <?php echo "one" ?> is valid (not error) but get in the habit of closing them.. okay i hope that clears things up.. EDIT: As your offline I have marked this as solved, (you can un/solve it with the button bottom left) you can still post here but it save time for members willing to help
  17. Yes i understood and my last reply still applies! post.php need to capture the POST and use cURL to send to another server.. however your code sends an empty post as you didn't send any post data, what my lines does is use the received post and add's it to the cURL.
  18. okay I have created a sample, that you will probably need to tweak, but it should get to started <?php $filename = "White-Cat.jpg"; $width = 100; $height = 100; list($width_orig, $height_orig) = getimagesize($filename); $ratio_orig = $width_orig/$height_orig; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } // Create image instances $src = imagecreatefromjpeg($filename); $dest = imagecreatetruecolor($width+20, $height+40); // Resample imagecopyresampled($dest, $src, 10, 10, 0, 0, $width, $height, $width_orig, $height_orig); //text $black = imagecolorallocate($dest, 0xFF, 0xFF, 0xFF); $font_file = 'arial.ttf'; //text Data //$url = file_get_contents("http://whereis.the/file/40x40.txt"); $url = "PHP Freaks"; imagefttext($dest, 10, 0, 13, $height+30, $black, $font_file, $url); // Output and free from memory header('Content-Type: image/jpeg'); imagejpeg($dest); imagedestroy($dest); imagedestroy($src); [attachment deleted by admin]
  19. You need to tell cURL what to post! See curl_setopt, CURLOPT_POSTFIELDS ie $POSTData = http_build_query($_POST); curl_setopt($ch, CURLOPT_POST, $POSTData);
  20. That's nice to know thanks.. Here is my Santa list: I'll like to be paid more and have more time off and a bigger.. wallet! EDIT: ahh a question, okay do you want to add text to the picture ? (as you opening a text file ?) if so look at imagettftext as for image on/in image imagecopymerge ie // Create image instances $dest = imagecreatefromgif('php.gif'); $src = imagecreatefromgif('php.gif'); // Copy and merge imagecopymerge($dest, $src, 10, 10, 0, 0, 100, 47, 75); // Output and free from memory header('Content-Type: image/gif'); imagegif($dest); imagedestroy($dest); imagedestroy($src);
  21. change else { echo ?> to else { ?>
  22. I'll like to point out 2 things, (number 2 is the big one) 1. that someone may workout that the hash is the sha1 of the time, to make them work harder you could add salt, for example $salt = "long unique string but must be the same as the one on the form"; if($_POST['hash'] == sha1($_POST['ntime'].$salt) ){ //VALID } <?php $salt = "long unique string but must be the same as the one on the form"; ?><input type="hidden" name="hash" value="<?php echo sha1($_GET['ftime'].$salt);?>"> <input type="hidden" name="ntime" value="<?php echo $_GET['ftime'];?>"> 2 . this page generates the time and the hash from the URL, this means anyone who visits the page could just simply change the URL and the new time and hash will be generated, Now i am going to assume that you have no control over that and the game passes the data via a GET.. so a middle option maybe this <?php session_start(); $_SESSION['ftime'] = $_GET['ftime']; //save time to session header("Location: Game.php"); //redirect to game.php <?php session_start(); if(empty($_SESSION['ftime']) || empty($_POST['sname'])) exit("Invalid Data!"); mysql_connect("localhost", "","") or die("error"); mysql_select_db("scoreboard") or die("error!"); // $time = $_POST["timer"]; $query = sprintf("INSERT INTO score VALUES('%s','%s')", mysql_real_escape_string($_POST['sname']), mysql_real_escape_string($_SESSION['ftime'])); $result = mysql_query($query); unset($_SESSION['ftime']); ?> Now your need to update your code so instead of passing ftime to scores.php you pass it to gateway.php (that will load up scores), Now if all that works correctly then your only need to post the sname to scores.php, and the URL for scores will not have the ?ftime= at the stop, But this still has the same problem because its using GET, and the user could just enter the URL gateway.php?ftime=whatever but theirs not much you can do about that unless you can use something other than GET, hence my second question
  23. first fix the SQL injection $name = $_POST["sname"]; $time = $_POST["ntime"]; $query = "INSERT INTO score VALUES('$name','$time')"; should be $query = sprintf("INSERT INTO score VALUES('%s','%s')", mysql_real_escape_string($_POST['sname']), mysql_real_escape_string($_POST['time'])); second.. where does the $_GET['ftime'] come from ? it would probably be better to use a session (in fact you could do the same for the name) EDIT: however..to answer your question in the form have <input type="hidden" name="hash" value="<?php echo sha1($_GET['ftime']);?>"> <input type="hidden" name="ntime" value="<?php echo $_GET['ftime'];?>"> and in PHP have if($_POST['hash'] == sha1($_POST['ntime']) ){ //VALID } you should also add salt..
  24. change <input type="hidden" value="<?php $_GET['ref']?>" name="refid"> to <input type="text" value="<?php $_GET['ref']?>" name="refid"> and check the value is in their if it is then do a print_r($_POST);
  25. magic quotes are EVIL and have been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. Relying on this feature is highly discouraged. so for using STRING's in SQL use mysql_real_escape_string
×
×
  • 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.