943,697 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 429
  • PHP RSS
Sep 8th, 2009
0

Basic code problem

Expand Post »
php Syntax (Toggle Plain Text)
  1. <?
  2. function outError($text){
  3. print "<center><b><font color = red>$text</font></b><br><br></center>";
  4. }

php Syntax (Toggle Plain Text)
  1. <option value="0" <?= ($installtype == "0") ? "selected" : ""; ?> >Install with CPanel Info (can create MySQL DB automatically)</option>


I have a script with such unusual tags and the script won't work. I cannot replace them since they are a thousands in number. And search and replace also didn't work.

thank you.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
gouthamvel is offline Offline
3 posts
since Mar 2008
Sep 8th, 2009
0

Re: Basic code problem

Hi gouthamvel and welcome to DaniWeb

I think we may need a bit more information to help you on this one. Can you please post the code for the select tag that this option tag is a part of? What do you mean by the script won't work? Does the page load? Is it just not displaying the options in the select? Are there any error messages? Is it the function that doesn't work as you would like and if so does anything happen when you call it?
Reputation Points: 395
Solved Threads: 192
Veteran Poster
darkagn is offline Offline
1,136 posts
since Aug 2007
Sep 8th, 2009
0

Re: Basic code problem

I have attached one of the file. I am confused with <?php and <?. I got a parse error when <? was used and when I replaced it with <?php the error got away. I use php 5.x, apache 2.2
Attached Files
File Type: php install.php (18.9 KB, 5 views)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
gouthamvel is offline Offline
3 posts
since Mar 2008
Sep 9th, 2009
0

Re: Basic code problem

I think these lines
php Syntax (Toggle Plain Text)
  1. <option value="0" <?php ($installtype == "0") ? "selected" : ""; ?> >Install with CPanel Info (can create MySQL DB automatically)</option>
should be
php Syntax (Toggle Plain Text)
  1. <option value="0" selected=<?php ($installtype == "0") ? "selected" : ""; ?> >Install with CPanel Info (can create MySQL DB automatically)</option>
Also, you should always use <?php in favour of the shorthand tags. Some servers do not support the shorthand tags, so for maximum compatibility use the longer version (it's only 3 more characters and the benefit is certainly worth it).
Reputation Points: 395
Solved Threads: 192
Veteran Poster
darkagn is offline Offline
1,136 posts
since Aug 2007
Sep 9th, 2009
1

Re: Basic code problem

Actually it should be as follows:
html Syntax (Toggle Plain Text)
  1. <option value="0" <?php echo ($installtype == "0" || $installtype == 0) ? "selected" : ""; ?> >Install with CPanel Info (can create MySQL DB automatically)</option>
Sponsor
Featured Poster
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
cwarn23 is offline Offline
3,004 posts
since Sep 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: sql syntax issue
Next Thread in PHP Forum Timeline: Forum Signature





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC