Re: [PHP] need help with code
Code without proper indentation and is very hard to comprehend. You have unnecessary spacing and line breaks that makes it difficult to debug. I suggest you few things as a good practice: 1) Until you learn perfectly to code use some nice GUI editors that have syntax highlighting (aptana, eclipse, zend etc). 2) Don't try to mix up markup (html) and api calls(PHP Code). Believe it become a horrible mess to maintain after some point. Anyways Here is your code with parse error removed: ?php require_once('twitterlib.php'); $consumerKey=yVVRd1QCJYBtT8tT7ocg; $consumerSecret=DHzhJYOP2hBWfHpHawGxRQEFf98nF4TBTfabel2ukE; $accessToken = $_COOKIE['accessToken']; $reqToken = $_COOKIE['reqToken']; if($accessToken===NULL){ if ($reqToken === NULL){ //get a req token $to = new TwitterOAuth($consumerKey, $consumerSecret); $tok = $to-getRequestToken(); $reqToken = $tok['oauth_token']; $reqTokenSecret = $tok['oauth_token_secret']; $request_link = $to-getAuthorizeURL($toc); $content = 'Click on the link to go to twitter to authorize your account.'; $content .= 'br /a href='.$request_link.''.$request_link.'/a'; setCookie('reqToken',$reqToken,time()+(24*30*60*60),'/'); setCookie('reqTokenSecret',$reqTokenSecret,time()+(24*30*60*60),'/'); ? htmlheadtitleauthorize/title/headbody ?php echo $content;? /body/html ?php }else{ /* If the access tokens are already set skip to the API call */ if ($_COOKIE['accessToken']===NULL){ /* Create TwitterOAuth object with app key/secret and token key/secret from default phase */ $to = new TwitterOAuth($consumerKey,$consumerSecret,$_COOKIE['reqToken'],$_COOKIE['reqTokenSecret']); /* Request access tokens from twitter */ $tok = $to-getAccessToken(); /* Save the access tokens. Normally these would be saved in a database for future use.*/ setCookie('accessToken',$tok['oauth_token'],time()*24*60*60*30+3600,'/'); setCookie('accessTokenSecret',$tok['oauth_token_secret'],time()*24*60*60*30,'/'); header(location http://www.chriswestbrook.com/twitter/twitter.php;); } } } ? Thanks, V
[PHP] need help with code
I hate asking for help with simple code like this because I can usually figure it out, but I'm stumped on this one. I'm getting a parser error on line 13, whether I comment out the require_once line or not. Can you help? ?php require_once('twitterlib.php'); $consumerKey=yVVRd1QCJYBtT8tT7ocg; $consumerSecret=DHzhJYOP2hBWfHpHawGxRQEFf98nF4TBTfabel2ukE; $accessToken = $_COOKIE['accessToken']; $reqToken = $_COOKIE['reqToken']; if ($accessToken===NULL) { if ($reqToken === NULL) { //get a req token $to = new TwitterOAuth($consumerKey, $consumerSecret); $tok = $to-getRequestToken(); $reqToken = $tok['oauth_token']; $reqTokenSecret = $tok['oauth_token_secret']; $request_link = $to-getAuthorizeURL($toc); $content = 'Click on the link to go to twitter to authorize your account.'; $content .= 'br /a href='.$request_link.''.$request_link.'/a'; setCookie('reqToken',$reqToken,time()+(24*30*60*60),'/'); setCookie('reqTokenSecret',$reqTokenSecret,time()+(24*30*60*60),'/'); ? htmlheadtitleauthorize/title/headbody ?php echo $content;? /body/html ?php } else { /* If the access tokens are already set skip to the API call */ if ($_COOKIE['accessToken']===NULL) { /* Create TwitterOAuth object with app key/secret and token key/secret from default phase */ $to = new TwitterOAuth($consumerKey,$consumerSecret,$_COOKIE['reqToken'],$_COOKIE['reqTokenSecret']); /* Request access tokens from twitter */ $tok = $to-getAccessToken(); /* Save the access tokens. Normally these would be saved in a database for future use. */ setCookie('accessToken',tok['oauth_token'],time()*24*60*60*30,'/') setCookie('accessTokenSecret',tok['oauth_token_secret'],time()*24*60*60*30,'/') header(location http://www.chriswestbrook.com/twitter/twitter.php;); } } ?
Re: [PHP] need help with code
On Sat, Mar 21, 2009 at 10:42, Chris Westbrook westbch...@gmail.com wrote: I hate asking for help with simple code like this because I can usually figure it out, but I'm stumped on this one. I'm getting a parser error on line 13, whether I comment out the require_once line or not. Can you help? Probably, but we'll need the error message and the code on the offending line. My guess from what you've shown in the code below is that line 13: $to = new TwitterOAuth($consumerKey, $consumerSecret); is telling you that it doesn't know TwitterOAuth(). And if that's the case, are you sure that it's properly defined and being included as appropriate from twitterlib.php? ?php require_once('twitterlib.php'); $consumerKey=yVVRd1QCJYBtT8tT7ocg; $consumerSecret=DHzhJYOP2hBWfHpHawGxRQEFf98nF4TBTfabel2ukE; $accessToken = $_COOKIE['accessToken']; $reqToken = $_COOKIE['reqToken']; if ($accessToken===NULL) { if ($reqToken === NULL) { //get a req token $to = new TwitterOAuth($consumerKey, $consumerSecret); $tok = $to-getRequestToken(); $reqToken = $tok['oauth_token']; $reqTokenSecret = $tok['oauth_token_secret']; $request_link = $to-getAuthorizeURL($toc); $content = 'Click on the link to go to twitter to authorize your account.'; $content .= 'br /a href='.$request_link.''.$request_link.'/a'; setCookie('reqToken',$reqToken,time()+(24*30*60*60),'/'); setCookie('reqTokenSecret',$reqTokenSecret,time()+(24*30*60*60),'/'); ? htmlheadtitleauthorize/title/headbody ?php echo $content;? /body/html ?php } else { /* If the access tokens are already set skip to the API call */ if ($_COOKIE['accessToken']===NULL) { /* Create TwitterOAuth object with app key/secret and token key/secret from default phase */ $to = new TwitterOAuth($consumerKey,$consumerSecret,$_COOKIE['reqToken'],$_COOKIE['reqTokenSecret']); /* Request access tokens from twitter */ $tok = $to-getAccessToken(); /* Save the access tokens. Normally these would be saved in a database for future use. */ setCookie('accessToken',tok['oauth_token'],time()*24*60*60*30,'/') setCookie('accessTokenSecret',tok['oauth_token_secret'],time()*24*60*60*30,'/') header(location http://www.chriswestbrook.com/twitter/twitter.php;); } } ? -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] need help with code
I hate asking for help with simple code like this because I can usually figure it out, but I'm stumped on this one. I'm getting a parser error on line 13, whether I comment out the require_once line or not. Can you help? ?php require_once('twitterlib.php'); $consumerKey=yVVRd1QCJYBtT8tT7ocg; $consumerSecret=DHzhJYOP2hBWfHpHawGxRQEFf98nF4TBTfabel2ukE; $accessToken = $_COOKIE['accessToken']; $reqToken = $_COOKIE['reqToken']; if ($accessToken===NULL) { if ($reqToken === NULL) { //get a req token $to = new TwitterOAuth($consumerKey, $consumerSecret); $tok = $to-getRequestToken(); $reqToken = $tok['oauth_token']; $reqTokenSecret = $tok['oauth_token_secret']; $request_link = $to-getAuthorizeURL($toc); $content = 'Click on the link to go to twitter to authorize your account.'; $content .= 'br /a href='.$request_link.''.$request_link.'/a'; setCookie('reqToken',$reqToken,time()+(24*30*60*60),'/'); setCookie('reqTokenSecret',$reqTokenSecret,time()+(24*30*60*60),'/'); ? htmlheadtitleauthorize/title/headbody ?php echo $content;? /body/html ?php } else { /* If the access tokens are already set skip to the API call */ if ($_COOKIE['accessToken']===NULL) { /* Create TwitterOAuth object with app key/secret and token key/secret from default phase */ $to = new TwitterOAuth($consumerKey,$consumerSecret,$_COOKIE['reqToken'],$_COOKIE['reqTokenSecret']); /* Request access tokens from twitter */ $tok = $to-getAccessToken(); /* Save the access tokens. Normally these would be saved in a database for future use. */ setCookie('accessToken',tok['oauth_token'],time()*24*60*60*30,'/') setCookie('accessTokenSecret',tok['oauth_token_secret'],time()*24*60*60*30,'/') header(location http://www.chriswestbrook.com/twitter/twitter.php;); } } ? hi Chris, basing on the code you posted, you're missing the closing brace for if ($accessToken===NULL) { there should be 3 closing braces before the last ? cheers, Virgil http://www.jampmark.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] need help with code
On Sat, Mar 21, 2009 at 10:54, Virgilio Quilario virgilio.quila...@gmail.com wrote: hi Chris, basing on the code you posted, you're missing the closing brace for if ($accessToken===NULL) { there should be 3 closing braces before the last ? That'll be the next error, but that error would print unexpected $end on line xxx. -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] need help with code
hi Chris, basing on the code you posted, you're missing the closing brace for if ($accessToken===NULL) { there should be 3 closing braces before the last ? That'll be the next error, but that error would print unexpected $end on line xxx. well, if you're getting the parse error without additional description then it must be the php versions because the lib might be throwing exceptions and you are running php4. cheers, Virgil http://www.jampmark.com Free tips, tutorials, innovative tools and techniques useful for building and improving web sites. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] need help/sample code for php/apache/imagemagick
hi... i'm considering creating a short test app/game to allow users to use their mouse to select items from a given image/pic. i'd like to be able to take some basic shapes, and construct an image/mosaic from them. i'd then like to be able to display the image to the user, and have the user select various shapes in the image. i'd also like to be able to determine what 'shape' the user is selecting within the image via the mouse coordinates... any ideas as to how this can be quickly developed/thrown together for testing... i kind of thought that this should be doable with php/imagemajick as an apache app.. thanks -bruce [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] need help/sample code for php/apache/imagemagick
For the determining what part of the picture the user is refering to I'd use image maps - which depending on your situation can be serverside, or clientside. I wouldn't bother with imagemagick, in this case, and just stick to gd. On 6/17/05, bruce [EMAIL PROTECTED] wrote: hi... i'm considering creating a short test app/game to allow users to use their mouse to select items from a given image/pic. i'd like to be able to take some basic shapes, and construct an image/mosaic from them. i'd then like to be able to display the image to the user, and have the user select various shapes in the image. i'd also like to be able to determine what 'shape' the user is selecting within the image via the mouse coordinates... any ideas as to how this can be quickly developed/thrown together for testing... i kind of thought that this should be doable with php/imagemajick as an apache app.. thanks -bruce [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Need Help Troubleshooting Code That Works Till It Comes to Form at End
I spent last night trying, overnight brooding (in my sleep), and this morning, finally, finding and fixing the errant line in the code below to get it to display in my browser the entries I made in a test name named users. So I got is to display every column of every entry. But when I tried a specialized select statement in the query box provided by the form at the very end of this code, when I pressed the Submit button, nothing changed; I was still left staring at the table of all the info in users. What am I missing in the form? Thanks much. Steve Tiano -- ?php if(!isset($query) || empty($query)) {$query = select * from users;} //stripslashes is necessary because the slect statement is //coming from a form. In most systems, the magic_quotes //setting (see Appendix A) will prepend single quotes //with backslashes, which could be problematic. $query=stripslashes($query); mysql_connect(localhost, name, password) or die (Could not connect to database); mysql_select_db(mysqlphp_db_apps_exerDB) or die (Could not select database); $result = mysql_query($query) or die(mysql_error() ); $number_cols = mysql_num_fields($result); echo bquery: $query/b; //lay out table header echo table border = 1\n; echo tr align=center\n; for ($i=0; $i$number_cols; $i++) { echo th . mysql_field_name($result, $i). /th\n; } echo /tr\n;//end table header //lay out table body while ($row = mysql_fetch_row($result)) { echo tr align=left\n; for ($i=0; $i$number_cols; $i++) { echo td; if (!isset($row[$i])) //test for null value {echo NULL;} else {echo $row[$i];} echo /td\n; } echo /tr\n; } echo /table; ? form action=? echo $PHP_SELF? method=GET input type=text name=query size=50br input type=submit /form -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need Help Troubleshooting Code That Works Till It Comes to Form at End
Stephen Tiano wrote: So I got is to display every column of every entry. But when I tried a specialized select statement in the query box provided by the form at the very end of this code, when I pressed the Submit button, nothing changed; I was still left staring at the table of all the info in users. [snip] if(!isset($query) || empty($query)) {$query = select * from users;} [snip] form action=? echo $PHP_SELF? method=GET input type=text name=query size=50br input type=submit /form Is register_globals ON or OFF? From you're code, you're assuming it's ON and $query will be created. If it's off, however, there will be no $query, only $_GET['query'] or $_REQUEST['query']. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] need help converting code to more efficient loop
Hello! I am trying to reduce the size of the code below, which I believe can be simplified. I checked the 'for' entry in the manual as well as googling for some similar code, but did not have any luck. Here is what I have: $ICON_COUNT=0; if ($SHOW_WAI_ICON != no) { $ICON_COUNT++ ; } if ($SHOW_BOBBY508_ICON != no) { $ICON_COUNT++ ; } if ($SHOW_W3_ICON != no) { $ICON_COUNT++ ; } if ($SHOW_CSS_ICON != no) { $ICON_COUNT++ ; } Now I would like to make that a 'for' loop, but I'm not sure how to do it in PHP. In case it is not clear what I am trying to do, this is what I would do if PHP syntax were like bash: variables=SHOW_CSS_ICON SHOW_W3_ICON SHOW_BOBBY508_ICON SHOW_WAI_ICON for i in $variables do if [ $i != no ] then #increment icon_count here fi done I'm just not sure about the nested syntax in PHP. Thanks for any help TjL -- Site: www.tntluoma.com mailto:[EMAIL PROTECTED] Info: Apache/1.3.19 (Unix) with PHP/4.0.6 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] need help converting code to more efficient loop
On Saturday 09 March 2002 18:08, Timothy J. Luoma wrote: Hello! I am trying to reduce the size of the code below, which I believe can be simplified. I checked the 'for' entry in the manual as well as googling for some similar code, but did not have any luck. Here is what I have: $ICON_COUNT=0; if ($SHOW_WAI_ICON != no) { $ICON_COUNT++ ; } if ($SHOW_BOBBY508_ICON != no) { $ICON_COUNT++ ; } if ($SHOW_W3_ICON != no) { $ICON_COUNT++ ; } if ($SHOW_CSS_ICON != no) { $ICON_COUNT++ ; } Now I would like to make that a 'for' loop, but I'm not sure how to do it in PHP. In case it is not clear what I am trying to do, this is what I would do if PHP syntax were like bash: variables=SHOW_CSS_ICON SHOW_W3_ICON SHOW_BOBBY508_ICON SHOW_WAI_ICON for i in $variables do if [ $i != no ] then #increment icon_count here fi done I'm just not sure about the nested syntax in PHP. $doo = array(SHOW_CSS_ICON, SHOW_W3_ICON); foreach($doo as $dah) { if (${$dah} != no) { $ICON_COUNT++; } } *** Untested, use with caution! *** -- Jason Wong - Gremlins Associates - www.gremlins.com.hk /* Don't put off for tomorrow what you can do today because if you enjoy it today, you can do it again tomorrow. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php