Welcome aboard Visitor...

Daily Screenshot

Server Costs Target


9% of target met.

Latest Topics

- Anyone still playing from a decade ago or longer? »
- Game still active. NICE! »
- Password resett »
- Darkspace Idea/Opinion Submission Thread »
- Rank Bug maybe? »
- Next patch .... »
- Nobody will remember me...but. »
- 22 years...asking for help from one community to another »
- DS on Ubuntu? »
- Medal Breakpoints »

Development Blog

- Roadmap »
- Hello strangers, it’s been a while... »
- State of DarkSpace Development »
- Potential planetary interdictor changes! »
- The Silent Cartographer »

Combat Kills

Combat kills in last 24 hours:
No kills today... yet.

Upcoming Events

- Weekly DarkSpace
05/11/24 +4.5 Days

Search

Anniversaries

1st - UntenHund

Social Media

Why not join us on Discord for a chat, or follow us on Twitter or Facebook for more information and fan updates?

Network

DarkSpace
DarkSpace - Beta
Palestar

[FAQ
Forum Index » » Soap Box » » PHP Newb In Need
 Author PHP Newb In Need
Little Pet Slinki
Admiral

Joined: April 16, 2006
Posts: 836
From: United Kingdom, South West.
Posted: 2007-05-17 14:25   
I literally started PHP yesterday and have hit a stumbling block.


$css = "";

$header =


$image_folder = "images/days";


$today = date('l');

if (file_exists($image_folder."/".$today.".gif")) {
echo "";
}
else {
echo "No image was found for $today";
}

?>

//Site title
$title = "Slinki For Prime Minister";
?>

So far I have that but it just comes up with "Parse error: syntax error, unexpected '?' in /home/jack2k4/public_html/dsftp/Slinki/config.php on line 8"

What I wanted was it to do a different picture every day of the week in the header area.. But Its not Biting. Any Help?
_________________


  Goto the website of Little Pet Slinki
Drafell
Grand Admiral
Mythica

Joined: May 30, 2003
Posts: 2449
From: United Kingdom
Posted: 2007-05-17 14:35   

$css = "";

//Set up function for header

function imageHeader()
{
$image_folder = "images/days";
$today = date('l');
if (file_exists($image_folder."/".$today.".gif")) {
echo "";
}
else {
echo "No image was found for $today";
}
}

$header = imageHeader();

//Site title
$title = "Slinki For Prime Minister";
?>


[ This Message was edited by: Drafell on 2007-05-17 14:43 ]
_________________
It's gone now, no longer here...Yet still I see, and still I fear.rnrn
rnrn
DarkSpace Developer - Retired

  Goto the website of Drafell
Little Pet Slinki
Admiral

Joined: April 16, 2006
Posts: 836
From: United Kingdom, South West.
Posted: 2007-05-17 14:40   
I can't connect to DS :l

ANYWAYS...

$header = "";

That was the original Header line.. but I didn't want the one banner i wanted it different days of the week as i tried to set out in teh above post.
_________________


  Goto the website of Little Pet Slinki
Drafell
Grand Admiral
Mythica

Joined: May 30, 2003
Posts: 2449
From: United Kingdom
Posted: 2007-05-17 14:45   
I see what you are doing now, see above post again...
_________________
It's gone now, no longer here...Yet still I see, and still I fear.rnrn
rnrn
DarkSpace Developer - Retired

  Goto the website of Drafell
Little Pet Slinki
Admiral

Joined: April 16, 2006
Posts: 836
From: United Kingdom, South West.
Posted: 2007-05-17 14:47   
Done that,

Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /home/jack2k4/public_html/dsftp/Slinki/config.php on line 12

But I got that :l


[ This Message was edited by: Little Pet of the Slinki Nebula on 2007-05-17 14:48 ]
_________________


  Goto the website of Little Pet Slinki
Drafell
Grand Admiral
Mythica

Joined: May 30, 2003
Posts: 2449
From: United Kingdom
Posted: 2007-05-17 14:49   
Oh yes, you have some errant ""'s in each other, that screws things up merrily..

$css = "";

//Set up function for header

function imageHeader()
{
$image_folder = "images/days";
$today = date('l');
if (file_exists($image_folder. "/" .$today. ".gif")) {
echo ""; // Correct version, I hope. I am a bit rusty.
}
else {
echo "No image was found for $today";
}
}

$header = imageHeader();

//Site title
$title = "Slinki For Prime Minister";
?>



[ This Message was edited by: Drafell on 2007-05-17 14:54 ]
_________________
It's gone now, no longer here...Yet still I see, and still I fear.rnrn
rnrn
DarkSpace Developer - Retired

  Goto the website of Drafell
Little Pet Slinki
Admiral

Joined: April 16, 2006
Posts: 836
From: United Kingdom, South West.
Posted: 2007-05-17 14:50   
Meaning I totally Cocked It Up?
_________________


  Goto the website of Little Pet Slinki
Little Pet Slinki
Admiral

Joined: April 16, 2006
Posts: 836
From: United Kingdom, South West.
Posted: 2007-05-17 15:14   
Fixed.. Ill update with more tails of my php misfortune later
_________________


  Goto the website of Little Pet Slinki
BackSlash
Marshal
Galactic Navy


Joined: March 23, 2003
Posts: 11183
From: Bristol, England
Posted: 2007-05-17 16:14   

function imageHeader() {
$image_folder = "images/days";
$today = date('l');
$header_url = $image_folder. "/" .$today. ".gif";

if (file_exists($header_url)) {
echo "";
} else {
echo "No image was found for $today";
}
}


Glad to see you're learning from the template I gave you

But you made a few mistakes:

1) You don't need to make "$header=" anything.
2) You don't need to enter

All you need to do to make the header display is type "imageHeader()" instead of echo $header. Or, if you want, you could make "$header = imageHeader()". I'm not sure if PHP likes having variables equal non-existant functions, so make sure the "$header = imageHeader()" is put after the function.

So it should look like this:




//Set CSS file
$css = "";


//Set imageHeader function
function imageHeader() {
$image_folder = "images/days";
$today = date('l');
$header_url = $image_folder. "/" .$today. ".gif";

if (file_exists($header_url)) {
echo "";
} else {
echo "No image was found for $today";
}
}

//Set header
$header = "imageHeader();";

//Site title
$title = "Slinki For Prime Minister";
?>




That should work just fine. You might need to go through every page later on and replace "echo $header;" with just "$header". But you've only got 4 from whatI can see, so that shouldn't be too hard. You could also just skip the whole $header = "imageHeader();"; mlarky in the config file, and just change "" into "" in all 4 pages. Up to you.

[ This Message was edited by: BackSlash *Jack* on 2007-05-17 16:24 ]
_________________


Coeus
Grand Admiral
Sundered Weimeriners


Joined: March 22, 2006
Posts: 2815
From: Philly
Posted: 2007-05-17 21:36   
/me walks into the thread
O.O

...

God speed boy.

/me runs away from the thread...
_________________
Do I really look like a guy with a plan?
'I'm gonna go crazy, and I'm taking you with me!'


ICC Security Council Chief Enforcer

  Email Coeus   Goto the website of Coeus
Page created in 0.020728 seconds.


Copyright © 2000 - 2024 Palestar Inc. All rights reserved worldwide.
Terms of use - DarkSpace is a Registered Trademark of PALESTAR