khopson Posted November 3, 2006 Share Posted November 3, 2006 I am at my wits end....I'm really trying to learn this stuff....but here is what's happening.$yr = "$_POST['year']";$month = "$_POST['month']";$day = "$_POST['day']";$week_str= "&weeknum=10&year=$yr&month=$month&day=$day&";echo "$week_str"I am using Flash client which calls this service with the year, month and day args. I am usingLoadVars() with the POST method. Here is what is returned to flash from my echo statement!weeknum = 10Year = $yrMonth = $monthDay = $daySo then I try to format it like this.....$week_str= "&weeknum=10&year=" .$yr. "&month=" .$month. "&day=" .$day. "&";Now the return looks like this....weeknum = 10Year = " .$yr. "Month = " .$month. "Day = " .$day. "I have tried everything I can think of.... Please...can anyone save my sanity here??Thanks in advance!!! Quote Link to comment Share on other sites More sharing options...
btherl Posted November 3, 2006 Share Posted November 3, 2006 Are you sure you are writing$week_str= "&weeknum=10&year=$yr&month=$month&day=$day&";And not$week_str= '&weeknum=10&year=$yr&month=$month&day=$day&';Notice the different quotes. Double quotes allow you to add variables in the string. Single quotes treat the string literally, and do not allow variables. Quote Link to comment Share on other sites More sharing options...
khopson Posted November 3, 2006 Author Share Posted November 3, 2006 Absolutely, Positively SURE!!!I tried doing double quotes and putting curl brackets around variables, single quotes inside of double quotes...everything I could think of to tell the interpreter that it is supposed to be a variable not a literal.....I'm out of ideas.... Quote Link to comment Share on other sites More sharing options...
doni49 Posted November 3, 2006 Share Posted November 3, 2006 I'm having trouble following what you're saying without seeing your code. And if this page is on the net, post the URL and I'll visit to see. Quote Link to comment Share on other sites More sharing options...
btherl Posted November 3, 2006 Share Posted November 3, 2006 I'm puzzled by this too.. Can you post your entire script inside code tags?[code]This is inside code tags.[/code]Click the # button above where you enter the post to insert code tags. Quote Link to comment Share on other sites More sharing options...
khopson Posted November 3, 2006 Author Share Posted November 3, 2006 OK...I'm so frustrated I'm probably not communicating very well....sorry..I have a flash program that calls a php service file using LoadVars() it goes like this...function getWeek(year,month,day) { fpath = "http://localhost:8500/Services/getWeekNum.php" var week_lv:LoadVars = new LoadVars(); week_lv.year = year; trace("LV year = "+week_lv.year); week_lv.month = month; week_lv.day = day; var reply_lv:LoadVars = new LoadVars(); reply_lv.onLoad = function(ok){ trace("OK = "+ok); if(ok){ trace("weeknum = "+reply_lv.weeknum); trace("Year = "+reply_lv.year); trace("Month = "+reply_lv.month); trace("Day = "+reply_lv.day); } else trace("error occurred: "+this.message); } week_lv.sendAndLoad(fpath,reply_lv,"POST");Now here's my php script..... in its entirety....Before you guys laugh too hard...I'm just a beginner so go easy on me.....<?phpif (!isset($_POST['year'])){ echo "Error=Cannot process without a given year&"; die(); }if (!isset($_POST['month'])) { echo "Error=Cannot process without a given month&"; die(); }if (!isset($_POST['day'])){ echo "Error=Cannot process without a given day&"; die(); }// Everything is here to start figuring the weeknumber$yr = "$_POST['year']";$month = "$_POST['month']";$day = "$_POST['day']";$week_str= "&weeknum=10&year=" .$yr. "&month=" .$month. "&day=" .$day. "&";echo "$week_str"?>Oh...I hope you guys can tell me what I'm doing wrong...I've been pounding this out for days...I've uninstalled and reinstalled php a million times....my web server a hundred times....well...you get the picture... Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted November 3, 2006 Share Posted November 3, 2006 Remove the double quotes from these lines:[code]<?php$yr = "$_POST['year']";$month = "$_POST['month']";$day = "$_POST['day']";?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
khopson Posted November 3, 2006 Author Share Posted November 3, 2006 Thanks Ken.... Here's the change I made:$yr = $_POST['year'];$month = $_POST['month'];$day = $_POST['day'];$week_str= "&weeknum=12&year=$yr&month=$month&day=$day&";Here's the output to Flash:weeknum = 12Year = $yrMonth = $monthDay = $dayAm I missing something in the string formatting? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted November 3, 2006 Share Posted November 3, 2006 I don't deal with flash, so I'm not familiar with debugging techniques used when interfacing with flash. If you echo something from the php script will it appear on the screen?If so, put this line at the start of your script:[code]<?phpecho '<pre>' . print_r($_POST,true) . '</pre>';?>[/code]This will dump to the screen the values the script is recieving in the $_POST arrary from the flash program. That may give us a hint as to the problem.Ken Quote Link to comment Share on other sites More sharing options...
btherl Posted November 3, 2006 Share Posted November 3, 2006 I copied and pasted your php, and it's fine.. the problem must be elsewhere. Though there is a small chance that something is odd with your php interpreter.You could make a simple form to test with:[code]<form action="http://localhost:8500/Services/getWeekNum.php" method=post><input type=text name=year value=1066><input type=text name=month value=1><input type=text name=day value=1><input type=submit name=submit></form>[/code] Quote Link to comment Share on other sites More sharing options...
doni49 Posted November 3, 2006 Share Posted November 3, 2006 If you're just trying to find the week number, why not just use PHP's date function?http://us3.php.net/date$weekNum = date("W");You can then do whatever you like with that value--echo it to the browser or send to flash. I don't use flash either. Quote Link to comment Share on other sites More sharing options...
khopson Posted November 3, 2006 Author Share Posted November 3, 2006 Gee...thanks for the advice on finding the week number....I hadn't gotten that far, yet...but was wondering how I was going to tackle that one?! I'm quite impressed if php has a function that will calculate that beast for me!!Anyway...I copied the simple form program you gave me, ran it...it ran fine, after clicking submit, the page came up absolutely blank. Nothing echoed!In fact, it came up blank running it through Dreamweaver. When I tried typing the address to the little form program directly into the browser like this: http://www.localhost/test.html I get "Cannot find Server" error message. (IE6) So I tried qualifying it a little better with http://localhost:8500/test.htmlstill received same error message.....as ND(Napolean Dynamite) would say..."GOSH!..DANG!!!I checked my services, even did a restart on the web server, but still errored when typing the address into the browser. I'm going from bad to worse here aren't I??? Quote Link to comment Share on other sites More sharing options...
khopson Posted November 3, 2006 Author Share Posted November 3, 2006 OK....I'm really getting tired...need sleep....I ran the test script in Firefox rather than IE6, and it ran ok.... I put Ken's suggestion in to echo the variables as follows: echo '<pre>' . print_r($_POST,true) . '</pre>'; I put this line in right after the <?>php tag. Here is what spewed out on the browser screen:' . print_r($_POST,true) . ''; if (!isset($_POST['year'])){ echo "Cannot process without a given Year!"; die(); } if (!isset($_POST['month'])) { echo "Cannot process without a given Month!"; die(); } if (!isset($_POST['day'])){ echo "Cannot process without a given Day!"; die(); } // Everything is here to start figuring the weeknumber $yr = $_POST['year']; $month = $_POST['month']; $day = $_POST['day']; $week_str= "&weeknum=13&year=$yr&month=$month&day=$day&"; echo $week_str ?>Is it the php interpreter that is choking? (I have installed PHP 5). It seems to see the echo statement and then just spew everything after it until there is no more to spew??? Doesn't seem to pay attention to the quotes, or anything???If I installed php 4.x Can I still get the date("W")??? Quote Link to comment Share on other sites More sharing options...
btherl Posted November 3, 2006 Share Posted November 3, 2006 I hope you mean the <?php tag, not the <?>php tag :)I think it's very unlikely that the problem is with the interpreter. That output there looks like what might happen if you accidentally left php mode and returned to html mode, with a '?>' for example.Did you include the '?>' from ken's example? If so, take it out and try again. Quote Link to comment Share on other sites More sharing options...
khopson Posted November 3, 2006 Author Share Posted November 3, 2006 OH....I just found the # sign you told me about earlier....cool!! (OK...I'll admit it I really am blonde!!)Here is the exact code in the php script. The tags look ok to me? The interpreter sees thebeginning tag, then the word "echo" then the '<pre>' tag. It echos alright, starting with the last single quote on the '<pre>' tag and all the way to the end of the document. It even echos the [quote]?>[/quote]?> tag. Is there a chance that it is being handled by the html and not even invoking the php interpreter? Or does the fact that it doesn't print the first[quote]<?php tag [/quote] and the first[quote]echo[/quote] mean that the interpreter was invoked but just didn't finish the job properly?[code]<?phpecho '<pre>' . print_r($_POST,true) . '</pre>';if (!isset($_POST['year'])){ echo "Cannot process without a given Year!"; die(); }if (!isset($_POST['month'])) { echo "Cannot process without a given Month!"; die(); }if (!isset($_POST['day'])){ echo "Cannot process without a given Day!"; die(); }// Everything is here to start figuring the weeknumber$yr = $_POST['year'];$month = $_POST['month'];$day = $_POST['day'];$week_str= "&weeknum=13&year=$yr&month=$month&day=$day&";echo $week_str?>[/code]Here's the output on the browser, again, I am using the form script supplied by [quote]btherl[/quote] to test. And also using the line provided by[quote]Ken[/quote] to echo the args coming into the script.' . print_r($_POST,true) . ''; if (!isset($_POST['year'])){ echo "Cannot process without a given Year!"; die(); } if (!isset($_POST['month'])) { echo "Cannot process without a given Month!"; die(); } if (!isset($_POST['day'])){ echo "Cannot process without a given Day!"; die(); } // Everything is here to start figuring the weeknumber $yr = $_POST['year']; $month = $_POST['month']; $day = $_POST['day']; $week_str= "&weeknum=13&year=$yr&month=$month&day=$day&"; echo $week_str ?>HuH!!! Coding is not for wimps!! It takes every bit of strength to keep from throwing this computer out the window!! (sorry...lost it for a minute). Quote Link to comment Share on other sites More sharing options...
doni49 Posted November 4, 2006 Share Posted November 4, 2006 I think I read that your filename has an HTML extension. Unless you TELL your server to run HTML files through the PHP engine, they WON'T. What will result is that the PHP code will be visible in the browser. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.