nightfox
Feb 5 2006, 04:17 AM
I have been working on a new template and I would like it so that if in the global configuration file, I have a variable for a global site announcement that would go on every page. The line in the global configuration file is this: CODE $announcement = "ANNOUNCEMENT"; In my template file, I could easily add CODE <?php echo $announcement; ?> but that would leave a blank space and with the announcement style (similar to the Invision Power Board error box). Is there some sort of script that could be put in the template page so I could have the global config file look something like this: CODE //Turn on announcement; 1 means on, 0 means off $announcementOn = 1
//Announcement Text: $announcement = "Blah"
Basically, if there is a "1" on $announcementOn, it enables code that echos the stylesheet class and displays the announcement in $announcement so when any page is displayed on the site, the announcement is shown. Thanks for any help! [N]F
Comment/Reply (w/o sign-up)
abhiram
Feb 5 2006, 04:24 AM
You could try: CODE
<?php if(isset($Announcement)) echo $Announcement; ?>
That should be sufficient, you don't need to add another variable.
Comment/Reply (w/o sign-up)
mastercomputers
Feb 5 2006, 10:06 AM
Is it possible you could show how your output looks? I'm trying to understand what you want in your last request: CODE <?php $announcementOn = true; $announcement = 'blah'; ?>
<?php if($announcementOn) echo $announcement; else{ ...do whatever you want... } ?>
I don't think I fully understood what you wanted, or why you have a mysterious blank, is this because $announcement is empty/null? Cheers, MC
Comment/Reply (w/o sign-up)
nightfox
Feb 5 2006, 05:41 PM
QUOTE(mastercomputers @ Feb 5 2006, 06:06 AM) I don't think I fully understood what you wanted, or why you have a mysterious blank, is this because $announcement is empty/null? Cheers, MC I don't have a mysterious blank... However, I think what abhiram suggested *MIGHT* work. I think this is how I would set it up on my template page: CODE <?php if(isset($announcement)) echo "<p class=\"announcement\">$announcement</p>"; ?>
Does that look correct? [N]F
Comment/Reply (w/o sign-up)
minnieadkins
Feb 6 2006, 08:33 PM
Looks like it would work to me. If $announcement is not set then you don't display anything, if it is you do. You could also use CODE if(!empty($announcement))
or CODE if($announcement)
an item is considered set in the following circumstance CODE $announcement = "";
Kinda good to know I s'pose.
Comment/Reply (w/o sign-up)
abhiram
Feb 7 2006, 02:14 AM
I guess minnieadkins is right. Thanks ... that's something I didnt' know. I thought 'empty=not set'.
Comment/Reply (w/o sign-up)
mastercomputers
Feb 8 2006, 01:51 AM
If that's supposedly correct then this would be your method: CODE <?php if( isset($announcement) && !empty($announcement) ){ echo '<p class="announcement">' . $announcement . '</p>'; } ?>
isset, checks if the variable is created, does not check it's contents, !empty checks for content. !empty, checks if the variable has information, if it didn't pass the isset it will not do this expression, so the variable must exist first. You should not do if($announcement), as you need to check if the variable exists before performing anything on it. This will result in a warning if the variable does not exist. Cheers, MC
Comment/Reply (w/o sign-up)
CrazyPensil
Mar 21 2006, 09:29 AM
simply, CODE <?php include("config.cfg"); if($announcementOn) { if($announcement) { print $announcement; } else { print "No announcement!"; } } ?>
Comment/Reply (w/o sign-up)
Quatrux
Mar 21 2006, 03:12 PM
Well, I would do like mastercomputers suggested it, because it is not recommended to do it like you showed above. But why use empty and isset at the same variable (a comment for mastercomputers) I saw people do it like this too, they said that this is just their programming style.. empty also checks if the variable is set (or better saying, that it does not throw a warning error if the variable is not set) and checks if it is == "" or 0 or "0" or NULL or FALSE or array() so I would do it: CODE <?php if ( !empty($announcement) ) { echo '<p class="announcement">' . $announcement . '</p>'; } ?>
everything clearly is written here: http://php.net/empty but anyway, I think this is to simple, to discuss it 
Comment/Reply (w/o sign-up)
Similar Topics
Keywords : Display Text Empty Config File- Php Random Text Generating
- How to Generate Random Text (11)
I was trying to figure out how to make random texts for random passwords and stuff, and I found
someone who created this code. QUOTE //author: polmme $codelenght = 10;
while($newcode_length $x=1; $y=3; $part = rand($x,$y); if($part==1){$a=48;$b=57;} // Numbers
if($part==2){$a=65;$b=90;} // UpperCase if($part==3){$a=97;$b=122;} // LowerCase
$code_part=chr(rand($a,$b)); $newcode_length = $newcode_length + 1; $newcode = $newcode.$code_part;
} echo $newcode; ?> I think it's pretty good. If anyone has a better one or suggestions,
please tell me....
Online HTML/PHP Editor: Edit File In Browser!
- (12)
Im wondering how you can load a file into a text area and edit it. Lets say i have a php file called
test.php and id like this file to be loaded into a textarea and the user should be able to edit this
file and store it. Is this posible? Im also wondering how you make it so the html dosnt get
encoded by the browser, lets say i need to explain on my website how you use html. CODE Just
testing something, maybe i can get this from the source. ...
Php Script To Download File From Another Site
- (11)
hi i need a php or java script code for downloading files from other sites to my site for example:
http://download.com/file.zip to http://mysite.com/file.zip thanks...
PHP Script To Upload A File
- with password-protection. (15)
Problem: Upload a file to the AstaHost account (that I have been granted here) throught the
webpage I would like to know, how should I proceed on this particular problem. I know this has
been done through cPanel, but I want to write a PHP functionality. The cPanel is accessed through
the 2082 port, and most of the places I access internet from does not give me access through that
port. I can access http://www.kmaheshbhat.astahost.com/ but not
http://www.kmaheshbhat.astahost.com/cpanel or http://www.kmaheshbhat.astahost.com:2082/ . I need
to go to one particu...
Counter With Img In Flat File
- (2)
this is a counter with images and stor in flat file becouse i can not upload .zip .rar file iwell
program it on this post at frist you need to 2 files count.php count.txt and you need else make
folder has name gifs and make 10 pictuer 10 file 0.gif to 9.gif now all ok open the count.php and
add this code CODE ### IMAGE FORMAT $format = ".gif"; $file = file("count.txt"); $num =
($file + 1); exec("echo $num > count.txt"); switch($type) { case "text": echo $num; break;
case "gfx": $i = 0; $cntn = strlen($num); while($i $tmpnum = subst...
How To Disable The Enter Key Of An Input Text Box
- (7)
Extplorer
- A PHP -and JavaScript- based File Manager (7)
Browsing the ExtJS examples website i found this excellent web-based file manager called
eXtplorer . eXtplorer allows you to browse your webserver folders with an intuitive Layout which
makes working with files very easy, and thanks to the great ExtJS Javascript Library you can drag
& drop folders and files, filter directories and sort the file list using various criteria. You can
use eXtplorer to for example: browse directories & files on the server. edit, copy, move, delete
files. search, upload and download files. create and extract archives. create new fil...
Php File Upload
- About uploading files through php (3)
Right i have done a check for a tutorial on this as well as a question about it but php is not
allowed in the search box. So i thought i'd just ask what i want to know. I have a form which
uploads a file, it refreshes the page, uploads the file and then alerts the user to if the file has
uploaded. To be honest im not sure why i keep getting the error. But here is the code: This is the
form that is used for the user to select the file &fid= " method="POST"> Choose a file to
upload: This is the upload code if ($op == "up"...
Automated File Structure Creation Script
- As Requested By Mark420 (3)
While chatting with Mark420 today on the shoutbox, he mentioned that he was looking for a script to
create his entire folder structure with just a click of a button. For example, he wanted the
following folders created in his root folder by just clicking submit. /images /images/thumbs
/images/icons /css /javascripts /content /content/articles /content/tutorials Presumably this
would be used for some type of installation system or other quick server setup situation. Anyhow
here is what I threw together for him: /* ********************************************...
How To Force A Zip File To Be Downloaded
- (11)
Hi, i have a problem with a zip file that i want to be force downloaded by any client, i know that
with the header function it can be achieved but dont know why it doesnt works. I have two files, the
first one is a simple html file with an a tag and the second is a php file, here is my code: html
file: CODE Download File Php file: CODE header('Content-Type:
application/zip'); header('Content-Disposition: attachment; filename="file.zip"');
readfile('downloads/file.zip'); ?> May be i forgot something, does it is necessary to ...
How To Delete File Using PHP Shell Script
- (3)
i have this problem regarding file access seems that my admin host or the server system itself have
locked up the acces to create new file, delete a file.. change file permissions and such controls
to file.. someone told me to use php shell script.. can you help me out here? ******** i just
need to find out how to use php shell script and add it to my php scripts to delete a file.. thanks...
Updating An Rss File Using A Php Form
- (1)
Hi, I'm currently making a site for my organization but I'm stuck on this one section where
I would have to make a PHP form in order for other members to post an item into my RSS file. So does
anyone know a PHP script I can use in order for me and other members to input a new RSS item into my
news RSS file?...
File Self Secure?
- is it avaible (6)
I just learn php. We store the pass word of Mysql in a file right. So is there any way to may a pass
protect that file . i mean they could hack and find out the place of the file (ex like in forum) and
drop all sercure data /huh.gif" style="vertical-align:middle" emoid=":huh:" border="0"
alt="huh.gif" />...
Xgrid With Php
- Creating a script to post a blender file to Xgrid using PHP (0)
I am doing pre planning for the blenderxgrid.com script. I was originally going to do this with
PERL, but elected against it. Eventually I'll be moving the site off astahost and replacing it
with a website hosted on the same machine as the xgrid controller. I am setting up a test version
on my latop using OSX's apache server, MySQL, and PHP on a localhost config. Here is my step
list for the script: ------------------------------------- Form: (within Xoops CMS, so user will
have to be logged in) Username Password (where they can upload the .blend file...
How To Embed Ram File Produced By Http Header
- (2)
Dear Friends I want to stream music from my website. The file format is .rm. People say that one
need a Helix Server or other media server to stream. I have found a solution to this problem as
well. I read an article about streaming music. It tells that if the size of the media file is small
and the byte rate of the media file is lower than that of the user internet connections byte rate,
the file get streamed automatically from HTTP server. In theory, any file is "streamed" by a web
server that is, sent back to the client in small pieces. What makes media files speci...
Generating A Table Into A File In CSV Format
- and letting user download the file (6)
I'm working on a project, part of which consists of working with large tables of different
kinds. Now, I'm using a page seeking technique which allows you to browse through the records
depending on which page you want to see and how many records you want to see on each page. Now, I
need a link (or a form button) on each page which, when clicked, will throw a file to the user for
download (the download window should popup immediatly) which will give the part of the table,
currently being viewed, in CSV format. One way I can think of to generate the file is manu...
PHP File Upload Works... But Stupid IE
- (3)
ok i have used the following code in my upload.php file Code: CODE $uploaddir =
'../photos/'; $uploadfile = $uploaddir . basename($_FILES ); echo ' '; if
(move_uploaded_file($_FILES , $uploadfile)) { echo "File is valid, and was successfully
uploaded.\n"; } else { echo "Possible file upload attack!\n"; } using ../photos/ as my
upload DIR works, as the file does upload, but when i echo $uploadfile on the same page: Code:
CODE " alt="uploadedfile" /> IE wont show it as it has two fullstops before the photo dir
in the domain...
Php/mysql Data Display
- (3)
Okay .. got a bit of a question here, so I'll do some explaining. I was asked to do a site for
an online roleplaying game, specifically, a "blackbook" site. I accepted and began my quest for
knowledge of PHP. I've gotten quite "far" to the point that I can now take a user inputted
search value and query the database with that value, and then display the values in a table. My
MySQL table setup is as below: CODE |Name|Reports|Type1|Type2|Quote|Confirmed| When queried
it displays the following: CODE Violator Name: # Reports: Offense(s): Quote: ...
I Need Help
- php display (2)
this is the original script i made CODE # include file include ("connect.php");
$db=mysql_select_db(unknow,$connection); $sql="SELECT id, Game_name, Game_link, Game_image
,Game_from FROM `Games` ORDER BY id"; $mysql_result=mysql_query($sql);
$num_rows=mysql_num_rows($mysql_result); if ( $num_rows == 0) { echo "Sorry there is no information
in that database please come back later"; } else { # we have result #create table WHILE
($row=mysql_fetch_array($mysql_result)) { $id=$row ; $Game_name=$row ; $Game_link=$row ;
$Game_image=$row ; echo " "; ...
Php: Write Random Text As Image
- Having problems, help needed! (3)
I'm trying to create a script that writes text to an image. CODE header("Content-type:
image/png"); $_phrases = array( "Test 1", "Test 2", "Test 3", "Test 4", "etc." );
$_rand_phrase = $_phrases ; $_image = imagecreatefrompng("gmail.png"); $_user_width =
imaagettfbbox(9,0,"tahoma.ttf",$_rand_phrase); $_x_value = (200-($user_width + 113)); $_color =
imagecolorallocate($_image, 165, 164, 164); imagettftext($_image, 9, 0, $_x_value, 16, $_color,
"tahoma.ttf", $_rand_phrase); imagepng($_image); imagedestroy($_image); I can't see what
I'm doing w...
Php Reading And Writing To File
- the code is very esay (4)
this code to Read from file you can use this code in to make a small data base and it is very to
use CODE $fp = fopen ("file.txt", "r"); $bytes = 4; $buffer = fread($fp, $bytes); fclose
($fp); print $buffer; ------------------- to write to same file CODE $fp = fopen
("file.txt", "w+"); fwrite ($fp, "Test"); fclose ($fp); ---------------- thanks and iwait the
commant...
In Php, How To Not Display Mysql Connection Error?
- Don't want mysql_connect() message (4)
In PHP, if the mysql database server cannot be connected, for example database server is handed or
turned off, an error message will be displayed: Warning: mysql_connect(): Unknown MySQL Server Host
"mysql.example.com" ... My question is how to not display this warning message? or can I customise
the error message? if so, how? Thank you....
Looking for display, text, line, empty, config, file
|
See Also,
*SIMILAR VIDEOS*
Searching Video's for display, text, line, empty, config, file
|
advertisement
|
|