Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Sponsored Reviews   1,000 Directory Submissions   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 06-23-2004, 07:46 AM   #1 (permalink)
Inactive
 
Pipeline-Webdesign's Avatar
 
Join Date: 02-11-04
Location: Corpus Christi, TX
Posts: 901
iTrader: 0 / 0%
Latest Blog:
None

Pipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the rough
Send a message via AIM to Pipeline-Webdesign Send a message via MSN to Pipeline-Webdesign Send a message via Yahoo to Pipeline-Webdesign
[solved]PHP Code causing Parse error

[code:1:8b10f85e67]if ($from == '') { if ($office == 'corporate') { echo "selected"; } } else { if ($from == 'corporate') { echo "selected"; } }[/code:1:8b10f85e67]

any reason this would cause a parse error?
Pipeline-Webdesign is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 06-23-2004, 07:54 AM   #2 (permalink)
SVB
Inactive
 
SVB's Avatar
 
Join Date: 10-13-03
Posts: 7,481
iTrader: 0 / 0%
Latest Blog:
None

SVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest order
Send a message via Yahoo to SVB
That looks ok to me, it must be something before or after. Show some more code
SVB is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-23-2004, 07:56 AM   #3 (permalink)
Inactive
 
Pipeline-Webdesign's Avatar
 
Join Date: 02-11-04
Location: Corpus Christi, TX
Posts: 901
iTrader: 0 / 0%
Latest Blog:
None

Pipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the rough
Send a message via AIM to Pipeline-Webdesign Send a message via MSN to Pipeline-Webdesign Send a message via Yahoo to Pipeline-Webdesign
[code:1:a5547a738e] <td width="493"><p align="left">Where are you coming from?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<select class="jumpmenu" name="from" onChange="MM_jumpMenu('parent',this,1)">
<option value="#">----------------------------- </option>
<option value="maps.php?office=corporate&from=corpus" <?php if ($from == '') { if ($office == 'corporate') { echo "selected"; } } else { if ($from == 'corporate') { echo "selected"; } } ?>>Corpus Christi</option>
<option value="maps.php?office=corporate&from=mcallen" <?php if ($from == '') { if ($office == 'mcallen') { echo "selected"; } } else { if ($from == 'mcallen') { echo "selected"; } } } ?>>McAllen</option>
<option value="maps.php?office=corporate&from=sanantonio" <?php if ($from == '') { if ($office == 'sanantonio') { echo "selected"; } } else { if ($from == 'sanantonio') { echo "selected"; } } } ?>>San Antonio</option>
<option value="maps.php?office=corporate&from=houston" <?php if ($from == '') { if ($office == 'houston') { echo "selected"; } } else { if ($from == 'houston') { echo "selected"; } } } ?>>Houston</option>
<option value="maps.php?office=corporate&from=dallas" <?php if ($from == '') { if ($office == 'dallas') { echo "selected"; } } else { if ($from == 'dallas') { echo "selected"; } } } ?>>Dallas</option>
<option value="#">For Clients </option>
<option value="#">----------------------------- </option>
</select></p>[/code:1:a5547a738e]
Pipeline-Webdesign is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-23-2004, 08:28 AM   #4 (permalink)
Potato Monster
 
Immo's Avatar
 
Join Date: 03-26-04
Location: Chester, England
Posts: 3,894
iTrader: 0 / 0%
Immo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest order
Send a message via ICQ to Immo Send a message via AIM to Immo Send a message via MSN to Immo Send a message via Yahoo to Immo Send a message via Skype™ to Immo
Nope its wrong hang on.
__________________
I have become death, destroyer of worlds.
Immo is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-23-2004, 08:33 AM   #5 (permalink)
Potato Monster
 
Immo's Avatar
 
Join Date: 03-26-04
Location: Chester, England
Posts: 3,894
iTrader: 0 / 0%
Immo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest order
Send a message via ICQ to Immo Send a message via AIM to Immo Send a message via MSN to Immo Send a message via Yahoo to Immo Send a message via Skype™ to Immo
if ($from == "")
{
if ($office == "corporate")
{
echo "selected";
}
elseif ($from == 'corporate')
{
echo "selected";
}}

Technically thats correct however it looks wrong somehow. What exactly is the script trying to do?
__________________
I have become death, destroyer of worlds.
Immo is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-23-2004, 08:36 AM   #6 (permalink)
Potato Monster
 
Immo's Avatar
 
Join Date: 03-26-04
Location: Chester, England
Posts: 3,894
iTrader: 0 / 0%
Immo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest order
Send a message via ICQ to Immo Send a message via AIM to Immo Send a message via MSN to Immo Send a message via Yahoo to Immo Send a message via Skype™ to Immo
I could probably write that code up for you easy enough. You had a few too many {} in there and one in the wrong place, also its better not to just do "if" statements as it can cause conflicts, use "elseif" or "else" instead
__________________
I have become death, destroyer of worlds.
Immo is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-23-2004, 08:42 AM   #7 (permalink)
Inactive
 
Pipeline-Webdesign's Avatar
 
Join Date: 02-11-04
Location: Corpus Christi, TX
Posts: 901
iTrader: 0 / 0%
Latest Blog:
None

Pipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the rough
Send a message via AIM to Pipeline-Webdesign Send a message via MSN to Pipeline-Webdesign Send a message via Yahoo to Pipeline-Webdesign
two variables are being grabbed from the address bar (i.e. posting.php?office=corporate&from=houston)

if 'from' is not there (i.e. posting.php?office=corporate) then i want it to check 'office', and if 'office' = corporate then i want it to echo selected. if 'from' is there then i want it to check if it = corporate and if it does, echo selected

if that's too confusing which it lookslike it is... i can send the whole code
Pipeline-Webdesign is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-23-2004, 08:44 AM   #8 (permalink)
Potato Monster
 
Immo's Avatar
 
Join Date: 03-26-04
Location: Chester, England
Posts: 3,894
iTrader: 0 / 0%
Immo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest order
Send a message via ICQ to Immo Send a message via AIM to Immo Send a message via MSN to Immo Send a message via Yahoo to Immo Send a message via Skype™ to Immo
Why are you doing it like that though? Is it to check that they have submitted the right data?
__________________
I have become death, destroyer of worlds.
Immo is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-23-2004, 08:48 AM   #9 (permalink)
Inactive
 
Pipeline-Webdesign's Avatar
 
Join Date: 02-11-04
Location: Corpus Christi, TX
Posts: 901
iTrader: 0 / 0%
Latest Blog:
None

Pipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the rough
Send a message via AIM to Pipeline-Webdesign Send a message via MSN to Pipeline-Webdesign Send a message via Yahoo to Pipeline-Webdesign
user visits (contactus.php)
---> user selects which office they want to see a map for (maps.php?office=####)
------> user selects from a dropdown box where they want directions to office FROM (maps.php?office=####&from=####)

i'm doing the check b/c when the user selects where they want directions FROM and it goes, i want the drop down box to "select" where they selected
Pipeline-Webdesign is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-23-2004, 08:56 AM   #10 (permalink)
Potato Monster
 
Immo's Avatar
 
Join Date: 03-26-04
Location: Chester, England
Posts: 3,894
iTrader: 0 / 0%
Immo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest order
Send a message via ICQ to Immo Send a message via AIM to Immo Send a message via MSN to Immo Send a message via Yahoo to Immo Send a message via Skype™ to Immo
Oh okay I get it. I think :S

Give me an hour and I will do it, just in the middle of something.
__________________
I have become death, destroyer of worlds.
Immo is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-23-2004, 09:04 AM   #11 (permalink)
Inactive
 
Pipeline-Webdesign's Avatar
 
Join Date: 02-11-04
Location: Corpus Christi, TX
Posts: 901
iTrader: 0 / 0%
Latest Blog:
None

Pipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the rough
Send a message via AIM to Pipeline-Webdesign Send a message via MSN to Pipeline-Webdesign Send a message via Yahoo to Pipeline-Webdesign
wow... i appreciate it... it shouldn't be too complicated... if you need anything just let me know
Pipeline-Webdesign is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-23-2004, 10:22 AM   #12 (permalink)
Potato Monster
 
Immo's Avatar
 
Join Date: 03-26-04
Location: Chester, England
Posts: 3,894
iTrader: 0 / 0%
Immo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest order
Send a message via ICQ to Immo Send a message via AIM to Immo Send a message via MSN to Immo Send a message via Yahoo to Immo Send a message via Skype™ to Immo
Hummm I think you could make this much easier.
__________________
I have become death, destroyer of worlds.
Immo is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-23-2004, 10:28 AM   #13 (permalink)
Potato Monster
 
Immo's Avatar
 
Join Date: 03-26-04
Location: Chester, England
Posts: 3,894
iTrader: 0 / 0%
Immo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest order
Send a message via ICQ to Immo Send a message via AIM to Immo Send a message via MSN to Immo Send a message via Yahoo to Immo Send a message via Skype™ to Immo
Can you paste the entire form for me or is this the only bit because if it is then all you need to do is set the action as,

<?php echo "maps.php?office=$office&" ?>

after that as long as you select the right name then it should work the rest out for you. Then you dont need all that php in the form like you have now.
__________________
I have become death, destroyer of worlds.
Immo is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-23-2004, 10:37 AM   #14 (permalink)
Inactive
 
Join Date: 06-01-04
Posts: 4
iTrader: 0 / 0%
Latest Blog:
None

AaronC is liked by many
First off, you're doing things a bit... uhm, well you're
making them more complicated than they need to be.

if ($from == '') { if $office == $corporate ...

The logic here is to use an AND statement.

<?php
if ((((empty($from)) AND ($office == 'corporate'))) OR ($from == 'corporate')) { echo "selected"; }
?>

That removes the mess. It also uses empty() instead of a blank
comparison, which also includes null and whitespace both.

Slightly easier to duplicate:

<?php
$location = 'corporate';
if ((((empty($from)) AND ($office == $location))) OR ($from == $location)) { echo "selected"; }
?>

Now just set $location as a test. I'd do this as function personally, but I won't
go that far yet.

[code:1:575ae55eed]
<td width="493">
<p align="left">Where are you coming from?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<select class="jumpmenu" name="from" onChange="MM_jumpMenu('parent',this,1)">
<option value="#">----------------------------- </option>
<option value="maps.php?office=corporate&from=corpus"
<?php
$location = 'corporate';
if ((((empty($from)) AND ($office == $location))) OR ($from == $location)) { echo "selected"; }
?>
>Corpus Christi</option>

<option value="maps.php?office=corporate&from=mcallen"
<?php
$location = 'mcallen';
if ((((empty($from)) AND ($office == $location))) OR ($from == $location)) { echo "selected"; }
?>
>McAllen</option>

<option value="maps.php?office=corporate&from=sanantonio"
<?php
$location = 'sanantonio';
if ((((empty($from)) AND ($office == $location))) OR ($from == $location)) { echo "selected"; }
?>
>San Antonio</option>

<option value="maps.php?office=corporate&from=houston"
<?php
$location = 'houston';
if ((((empty($from)) AND ($office == $location))) OR ($from == $location)) { echo "selected"; }
?>
>Houston</option>

<option value="maps.php?office=corporate&from=dallas"
<?php
$location = 'dallas';
if ((((empty($from)) AND ($office == $location))) OR ($from == $location)) { echo "selected"; }
?>
>Dallas</option>
<option value="#">For Clients </option>
<option value="#">----------------------------- </option>
</select></p>
[/code:1:575ae55eed]

This makes your code a LOT easier to read and debug. If something is wrong in the syntax, then it's wrong in all of them. I didn't test this beforehand, but it should give you a good idea about how you can proceed.

Now if you wanted to do a function then:

[code:1:575ae55eed]
<?php
function checkselected($location) {
global $from, $office;
if ((((empty($from)) AND ($office == $location)))
OR ($from == $location)) {
echo "selected";
}
}
?>

<td width="493">
<p align="left">Where are you coming from?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<select class="jumpmenu" name="from" onChange="MM_jumpMenu('parent',this,1)">
<option value="#">----------------------------- </option>

<option value="maps.php?office=corporate&from=corpus"
<?php checkselected('corporate'); ?>
>Corpus Christi</option>

<option value="maps.php?office=corporate&from=mcallen"
<?php checkselected('mcallen'); ?>
>McAllen</option>

<option value="maps.php?office=corporate&from=sanantonio"
<?php checkselected('sanantonio'); ?>
>San Antonio</option>

<option value="maps.php?office=corporate&from=houston"
<?php checkselected('houston'); ?>
>Houston</option>

<option value="maps.php?office=corporate&from=dallas"
<?php checkselected('dallas'); ?>
>Dallas</option>

<option value="#">For Clients </option>
<option value="#">----------------------------- </option>
</select></p>
[/code:1:575ae55eed]

Does that make sense? It may not work directly as written (might've missed a semicolon), but it's pretty dang close
AaronC is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-24-2004, 06:35 AM   #15 (permalink)
Potato Monster
 
Immo's Avatar
 
Join Date: 03-26-04
Location: Chester, England
Posts: 3,894
iTrader: 0 / 0%
Immo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest order
Send a message via ICQ to Immo Send a message via AIM to Immo Send a message via MSN to Immo Send a message via Yahoo to Immo Send a message via Skype™ to Immo
Did you get this sorted?
__________________
I have become death, destroyer of worlds.
Immo is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-24-2004, 06:51 AM   #16 (permalink)
Inactive
 
Pipeline-Webdesign's Avatar
 
Join Date: 02-11-04
Location: Corpus Christi, TX
Posts: 901
iTrader: 0 / 0%
Latest Blog:
None

Pipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the roughPipeline-Webdesign is a jewel in the rough
Send a message via AIM to Pipeline-Webdesign Send a message via MSN to Pipeline-Webdesign Send a message via Yahoo to Pipeline-Webdesign
My problem was probably a little confusing, but I figured out how to do it now.

Initially what I wanted to do was to test two variables.
The two variables I had were:
office and from

This is a script that will print directions TO the office from the city that the user selected from a choice represented as a dropdown box.

Basically it all starts with the Contact Us Page.
The user visits the contact us page and there are 5 offices that the user can click on. There is a link for each office that says:
(map).

Say I clicked on Corporate's link to the map; it would then goto a file called
maps.php?office=corporate

Once at that file, there is a dropdown box right above a general map asking
Where are you coming from?

When the user selects where they are coming from, depending on the selection it goes within the same link, but adds a variable. Say I clicked on
Houston.
It would then goto
maps.php?office=corporate&from=houston.

The reason i need two variables at this point, is b/c now I need to print the directions. The way I am going to have it setup, is depending on which
from
is selected, depends on which
include statement is initialized.

I know this is long and drawn out, but the whole point for the above script was when the user selected the from and it went to the two variable page, I wanted the selected value in the dropdown box to be the same that they just selected. TAKES A BREATH. Anyways, here is how the script turned out.

[code:1:7131243b69]
<td width="493"><p align="left">Where are you coming from?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<select class="jumpmenu" name="from" onChange="MM_jumpMenu('parent',this,1)">
<option value="#">----------------------------- </option>
<option value="maps.php?office=corporate&from=corpus" <?php if ($from == 'corporate') { echo "selected"; } if ($from == '') { if ($office == 'corporate') { echo "selected"; } } ?>>Corpus Christi</option>
<option value="maps.php?office=corporate&from=mcallen" <?php if ($from == 'mcallen') { echo "selected"; } if ($from == '') { if ($office == 'mcallen') { echo "selected"; } } ?>>McAllen</option>
<option value="maps.php?office=corporate&from=sanantonio" <?php if ($from == 'sanantonio') { echo "selected"; } if ($from == '') { if ($office == 'sanantonio') { echo "selected"; } } ?>>San Antonio</option>
<option value="maps.php?office=corporate&from=houston" <?php if ($from == 'houston') { echo "selected"; } if ($from == '') { if ($office == 'houston') { echo "selected"; } } ?>>Houston</option>
<option value="maps.php?office=corporate&from=dallas" <?php if ($from == 'dallas') { echo "selected"; } if ($from == '') { if ($office == 'dallas') { echo "selected"; } } ?>>Dallas</option>
<option value="#">For Clients </option>
<option value="#">----------------------------- </option></select>[/code:1:7131243b69]

SOO... in the code i tested $from first for the hard value. If it has that hard value, then it echo's "selected". Then I test for a null value for $from and if that's true, then it means someone got to the address by accident and not from a link so it then echo's whatever $office is at the time. Sorry for all the confusion.
Pipeline-Webdesign is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-24-2004, 07:08 AM   #17 (permalink)
Inactive
 
Pipeline-Webdesign's Avatar
 
Join Date: 02-11-04
Location: Corpus Christi, TX
Posts: 901
iTrader: 0 / 0%
Latest Blog:
None

Pipeline-Webdesign is a jewel in the rough