/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] it works one way, but not another?

okay, so i’m using phoogle. if anyone doesn’t know what it is, you can find it here: [url]http://www.systemsevendesigns.com/phoogle[/url]

i need to set the width of my map to 85%. but i also need to pull the address, city, state, venue from a variable.

this example works but in here i have written in the address:

[code=php]<?

$map->addAddress(‘615 E Washington Street, Louisville, KY’,’Sleep Chamber’);
$map->setWidth(‘85%’);
$map->setHeight(200);
$map->showMap();

?>[/code]

But this one doesn’t! This bottom one works when i change the width to 300, or any number, but as a percent it doesn’t work!

[code=php]<?

$map->addAddress(stripslashes($address).’ ‘.$city.’ ‘.$state, stripslashes($venue));
$map->setWidth(‘85%’);
$map->setHeight(200);
$map->showMap();

?>[/code]

does anybody have any idea why?

Thanks in advance!
-sheep

to post a comment
PHP

30 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 07.2007 — I don't know if/why this would have any bearing on the width issue, but to be consistent with the first example it seems like the first line should be:
[code=php]
$map->addAddress(stripslashes($address).', '.$city.', '.$state, stripslashes($venue));
[/code]
Copy linkTweet thisAlerts:
@SaveSheepauthorMar 07.2007 — ah, that is true.

now what about the ' that seperate the first half from the second half?

thank you
Copy linkTweet thisAlerts:
@NightShift58Mar 07.2007 — There's no single quote separating halves.

The single quotes are used to enclose literal commas inserted into your address line.

EDIT: I looked again. I understand now you didn't mean the single quote but the comma separating the parameters. In NogDog's snippet, it's still there, where it should be.
Copy linkTweet thisAlerts:
@SaveSheepauthorMar 07.2007 — it should write this:

'615 E Washington Street, Louisville, KY','Sleep Chamber'

with the single quotes on the left and right side of the venue name and of them address.

but instead it writes:

615 E Washington Street, Louisville, KY, Sleep Chamber


see what i mean?
Copy linkTweet thisAlerts:
@NightShift58Mar 07.2007 — I see what you mean and the results are correct.

This is the way it should be. If you are passing literal values, as in your original post, you would use single or double quotes. If you are passing variables - or the results of a function - no quotes are necessary and sometimes undesirable.

As the values passed are received by the function being called, the quotes "disappear".

NogDog's code is correct.
Copy linkTweet thisAlerts:
@SaveSheepauthorMar 08.2007 — hey again guys,

i did change it to his code, and it still doesn't work.

you can check it out by going to www.sheaallen.com/shows/submit2 - fill out all the forms that turn red with anything but make sure you put a valid address in

any other ideas?

thanks!
Copy linkTweet thisAlerts:
@NightShift58Mar 08.2007 — Just tried it. It seems to work.
Copy linkTweet thisAlerts:
@SaveSheepauthorMar 08.2007 — hmm, i don't see how? it doesn't work for me in mozilla or ie. atleast, it doesn't show a map. does yours show the map and everything no problem?
Copy linkTweet thisAlerts:
@NightShift58Mar 08.2007 — No map but it shows the address as entered somewhere in there.

I couldn't tell where a map is supposed to be.
Copy linkTweet thisAlerts:
@SaveSheepauthorMar 08.2007 — check out, www.sheaallen.com/shows/show1 - this is how it should look


so, once again, i'm not sure why it doesn't work
Copy linkTweet thisAlerts:
@NightShift58Mar 08.2007 — Obviously, the problem has to be somewhere else because the snippet posted by NogDog is functionally equivalent to your original one.

In other words:[code=php]<?
$map->addAddress('615 E Washington Street, Louisville, KY','Sleep Chamber');
$map->setWidth('85%');
$map->setHeight(200);
$map->showMap();
?>[/code]
is the same as this:[code=php]
$address = "615 E Washington Street";
$city = "Louisville";
$state = "KY";
$venue = "Sleep Chamber";
$map->addAddress(stripslashes($address) . ', ' . $city . ', ' . $state, stripslashes($venue));
?>[/code]
Try doing the following right before calling the map function:[code=php]
echo "<hr>";
echo stripslashes($address) . ', ' . $city . ', ' . $state;
echo "<br>";
echo stripslashes($venue);
echo "<hr>";
[/code]
Copy linkTweet thisAlerts:
@SaveSheepauthorMar 08.2007 — so do

<?

echo "<hr>";

echo stripslashes($address) . ', ' . $city . ', ' . $state;

echo "<br>";

echo stripslashes($venue);

echo "<hr>";

$map->addAddress(stripslashes($address) . ', ' . $city . ', ' . $state, stripslashes($venue));

$map->setWidth('85%');

$map->setHeight(200);

$map->showMap();

?>


I guess i don't see what you're getting at. Are you trying to see if the variables are even coming through? I mean, i'm 100% sure they are coming through just because they show up elsewhere on that review page.

If you go check it out, www.sheaallen.com/shows/submit2 - fill in all the red fields and it'll bring you to a page titled review. the left side of where the map should be states the address and venue name.
Copy linkTweet thisAlerts:
@SaveSheepauthorMar 08.2007 — Oh also,

as i stated earlier, the whole snippet works fine if i set the width to 300 or a defined pixel. make sense? Like it'll pull and show the map fine with a given width.

however, on the pages that don't pull variables, where i have the addresses directly printed into the php, where i also use 85% for the width, it works fine.

So it seems like the equation works only either or, not both variables and 85%.
Copy linkTweet thisAlerts:
@NightShift58Mar 08.2007 — We're working in a vacuum here because we can't look for the error in your code.

If you could post it, we'll find the error.
Copy linkTweet thisAlerts:
@NightShift58Mar 08.2007 — Got a copy. Please take it down - or at least the API key...
Copy linkTweet thisAlerts:
@NightShift58Mar 08.2007 — The problem is not NogDog's snippet, it is the 85%.

This is what the phoogle class is generating when you use a percentage sign:[code=php]<div id="map" style="width: 85%px; height: 200px">[/code]In other words, the "px" seems to be hardcoded into the class, which, of course, when used with your % doesn't add up to anything useful and the <div> can't/won't display.

Just for fun, a quick hack (not really recommended) would be to do this:[code=php]$map->setWidth('85%;padding-left:0');[/code].Better would be to compute the 85% yourself and then pass the desired number of pixels in SetWidth.
Copy linkTweet thisAlerts:
@SaveSheepauthorMar 08.2007 — well, the design is fluid. so the 85% differs depending on resolution.

But what gets me, is on the shows1 page...it uses 85% and works fine.

any idea what would cause this?
Copy linkTweet thisAlerts:
@NightShift58Mar 08.2007 — You have a point. In fact, the generate javascript is also identical for both.

I can't test it for lack of a valid API key, but let me look around...
Copy linkTweet thisAlerts:
@NightShift58Mar 08.2007 — The default in phoogle.php is 300px wide and the SetWidth function is designed to accept only integers. Nonetheless, layout fluidity is maintained.

Can you try this:[code=php]<?
$thisADDRESS = $address . ', ' . $city . ', ' . $state;
$thisVENUE = $venue;
$thisWIDTH = intval(300 * .85);
$map->addAddress($thisADDRESS, $thisVENUE);
$map->setWidth($thisWIDTH);
$map->setHeight(200);
$map->showMap();
?>[/code]
Copy linkTweet thisAlerts:
@NightShift58Mar 08.2007 — I broke down and got an API key:

http://www.nightshift58.com/webdev/test_phoogle.php

This is the map-calling code I use:[code=php] <?
$map->addAddress(stripslashes($address) . ", " . $city . ", " . $state, stripslashes($venue));
$map->setWidth(intval(300*.85));
$map->setHeight(200);
$map->showMap();
?>[/code]
So far, not too many differences. The one difference - one that could be a major one - is that, since I don't have a form to post from, I used this at the top of the script:[code=php]$venue = "Sleep Chamber";
$address = "615 E Washington Street";
$city = "Louisville";
$state = "KY";[/code]
to simulate user input.

If it works for me using that but doesn't work for you using the form, then something is happening between form submission and use of the variables.

Try using urldecode() to clean up any extraneous stuff that may be put in there.
Copy linkTweet thisAlerts:
@SaveSheepauthorMar 08.2007 — hey again,

i first want to thank you a lot for your time! you've been great help so far.

but i do have to ask, 300 *.85 is still a decimel figure. i mean, i may as well just put the number in there in the first place, right? i have a table that is 90% wide of the screen, on the left i have the table where the venue info goes, on the right i have another td which shows the google map in it. both td's are 50% wide. So the google map winds up being 85% of the 50% td. This way, if someone has a crazy big resolution...it fills up all that space. if they have a smaller resolution, it suffices. if i do the 300 * .85 then its going to be the same on every resolution, correct?


is there somewhere in the phoogle page which creates the px?

i hope i'm making sense.

thanks again!


p.s. - what is urldecode?
Copy linkTweet thisAlerts:
@SaveSheepauthorMar 08.2007 — line 239 in phoogle.php i changed to:

[code=php] echo "n<div id="map" width="".$this->mapWidth."" style="height: ".$this->mapHeight."px">n</div>n";[/code]

and it writes:

[code=html]<div id="map" width="85%" style="height: 200px">[/code]

yet, it still doesn't work...

i also tried the width=85% in the style tag. no change
Copy linkTweet thisAlerts:
@SaveSheepauthorMar 08.2007 — last but not least...the page show1 writes this:


[code=html]<div id="map" width="85%" style="height: 200px">[/code]

no difference here whatsoever. but this one...works?
Copy linkTweet thisAlerts:
@SaveSheepauthorMar 08.2007 — haha, i want to point this out.

i edited the show1 page to this:

[code=php]<?
$address = "615 E Washington Street";
$city = "Louisville";
$state = "KY";
$venue = "Sleep Chamber";
$map->addAddress(stripslashes($address) . ", " . $city . ", " . $state, stripslashes($venue));
$map->setWidth('85%');
$map->setHeight(200);
$map->showMap();

?>[/code]


and it works.
Copy linkTweet thisAlerts:
@SaveSheepauthorMar 08.2007 — i'm assuming the review page is putting some code before other code...which needs not to happen. just figuring out which it is.
Copy linkTweet thisAlerts:
@SaveSheepauthorMar 08.2007 — k, i copied the php over to the show1 page and i'm just rebuilding the review page off it one step at a time to see what variable threw it off. so far, everything is working just dandy!

www.sheaallen.com/shows/submit2 - then go to review

thanks for all your help nightshift!
Copy linkTweet thisAlerts:
@sitehatcheryMar 09.2007 — I've used yahoo maps with success. It's nearly identical except that it has the Yahoo logo on the bottom. For an example, http://www.chicohomeandgarden.com/driving-instructions.php

Just view source and get the code.

Also, I once had a problem with the map not showing, and doh, my Javascript was disabled. Might want to check that.
Copy linkTweet thisAlerts:
@NightShift58Mar 09.2007 — thanks for all your help nightshift![/QUOTE]You're welcome. I think I'm going to look at this map stuff. Never did it before, but I think it's pretty cool.
Copy linkTweet thisAlerts:
@SaveSheepauthorMar 09.2007 — nightshift,

do you work with php often? i have a bunch of tiny projects i'd like some help on. if they go anywhere, profits will be split. something you could be interested in?

-sheep
×

Success!

Help @SaveSheep spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...