Jump to content

What Am I Doing Wrong?


JesseToxik
Go to solution Solved by Psycho,

Recommended Posts

I tried converting a javascript code of mine to PHP and I really do not know what I am doing wrong.

It i supposed to get the day of the year and print out the corresponding quote to that day.

 

Help?

<?php
$today = date("z") + 1;

$Quote[0]='Quote goes here';
$Quote[1]='Quote goes here';
$Quote[2]='Quote goes here';
$Quote[3]='Quote goes here';
$Quote[4]='Quote goes here';
$Quote[5]='Quote goes here';
$Quote[6]='Quote goes here';
$Quote[7]='Quote goes here';
$Quote[8]='Quote goes here';
$Quote[9]='Quote goes here';
$Quote[10]='Quote goes here';
$Quote[11]='Quote goes here';
$Quote[12]='Quote goes here';
$Quote[13]='Quote goes here';
$Quote[14]='Quote goes here';
$Quote[15]='Quote goes here';
$Quote[16]='Quote goes here';
$Quote[17]='Quote goes here';
$Quote[18]='Quote goes here';
$Quote[19]='Quote goes here';
$Quote[20]='Quote goes here';
$Quote[21]='Quote goes here';
$Quote[22]='Quote goes here';
$Quote[23]='Quote goes here';
$Quote[24]='Quote goes here';
$Quote[25]='Quote goes here';
$Quote[26]='Quote goes here';
$Quote[27]='Quote goes here';
$Quote[28]='Quote goes here';
$Quote[29]='Quote goes here';
$Quote[30]='Quote goes here';
$Quote[31]='Quote goes here';
$Quote[32]='Quote goes here';
$Quote[33]='Quote goes here';
$Quote[34]='Quote goes here';
$Quote[35]='Quote goes here';
$Quote[36]='Quote goes here';
$Quote[37]='Quote goes here';
$Quote[38]='Quote goes here';
$Quote[39]='Quote goes here';
$Quote[40]='Quote goes here';
$Quote[41]='Quote goes here';
$Quote[42]='Quote goes here';
$Quote[43]='Quote goes here';
$Quote[44]='Quote goes here';
$Quote[45]='Quote goes here';
$Quote[46]='Quote goes here';
$Quote[47]='Quote goes here';
$Quote[48]='Quote goes here';
$Quote[49]='Quote goes here';
$Quote[50]='Quote goes here';
$Quote[51]='Quote goes here';
$Quote[52]='Quote goes here';
$Quote[53]='Quote goes here';
$Quote[54]='Quote goes here';
$Quote[55]='Quote goes here';
$Quote[56]='Quote goes here';
$Quote[57]='Quote goes here';
$Quote[58]='Quote goes here';
$Quote[59]='Quote goes here';
$Quote[60]='Quote goes here';
$Quote[61]='Quote goes here';
$Quote[62]='Quote goes here';
$Quote[63]='Quote goes here';
$Quote[64]='Quote goes here';
$Quote[65]='Quote goes here';
$Quote[66]='Quote goes here';
$Quote[67]='Quote goes here';
$Quote[68]='Quote goes here';
$Quote[69]='Quote goes here';
$Quote[70]='Quote goes here';
$Quote[71]='Quote goes here';
$Quote[72]='Quote goes here';
$Quote[73]='Quote goes here';
$Quote[74]='Quote goes here';
$Quote[75]='Quote goes here';
$Quote[76]='Quote goes here';
$Quote[77]='Quote goes here';
$Quote[78]='Quote goes here';
$Quote[79]='Quote goes here';
$Quote[80]='Quote goes here';
$Quote[81]='Quote goes here';
$Quote[82]='Quote goes here';
$Quote[83]='Quote goes here';
$Quote[84]='Quote goes here';
$Quote[85]='Quote goes here';
$Quote[86]='Quote goes here';
$Quote[87]='Quote goes here';
$Quote[88]='Quote goes here';
$Quote[89]='Quote goes here';
$Quote[90]='Quote goes here';
$Quote[91]='Quote goes here';
$Quote[92]='Quote goes here';
$Quote[93]='Quote goes here';
$Quote[94]='Quote goes here';
$Quote[95]='Quote goes here';
$Quote[96]='Quote goes here';
$Quote[97]='Quote goes here';
$Quote[98]='Quote goes here';
$Quote[99]='Quote goes here';
$Quote[100]='Quote goes here';
$Quote[101]='Quote goes here'
$Quote[102]='Quote goes here'
$Quote[103]='Quote goes here';
$Quote[104]='Quote goes here';
$Quote[105]='Quote goes here';
$Quote[106]='Quote goes here';
$Quote[107]='Quote goes here';
$Quote[108]='Quote goes here';
$Quote[109]='Quote goes here';
$Quote[110]='Quote goes here';
$Quote[111]='Quote goes here';
$Quote[112]='Quote goes here';
$Quote[113]='"People shouldn\'t be afraid of their government. Governments should be afraid of their people." - Alan Moore, V for Vendetta';
$Quote[114]='"The best and most beautiful things in the world cannot be seen or even touched - they must be felt with the heart." - Helen Keller';
$Quote[115]='"It is during our darkest moments that we must focus to see the light." - Aristotle Onassis';
$Quote[116]='“The beautiful thing about learning is that no one can take it away from you.” - B. B. King';
$Quote[117]='“Luck is what happens when preparation meets opportunity.” - Seneca';
$Quote[118]='“Courage is not the absence of fear, but rather the judgement that something else is more important than fear.” - James Neil Hollingworth';
$Quote[119]='“Those who wish to sing, always find a song.” - Swedish Proverb';
$Quote[120]='“The most powerful weapon on earth is the human soul on fire.” - Ferdinand Foch';
$Quote[121]='“He who is devoid of the power to forgive, is devoid of the power to love. ” - Martin Luther King Jr.';
$Quote[122]='“Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.” - Josh Billings';
$Quote[123]='“Whoever said anybody has a right to give up? ” - Marian Wright Edelman';
$Quote[124]='“Enthusiasm is the mother of effort, and without it nothing great was ever achieved.” - Ralph Waldo Emerson';
$Quote[125]='“There are no traffic jams along the extra mile.” - Roger Staubach';
$Quote[126]='“The difference between try and triumph is a little umph. ” - Anonymous';
$Quote[127]='“Men exist for the sake of one another. Teach them then or bear with them.” - Marcus Aurelius Antoninus';
$Quote[128]='“It is in the shelter of each other that the people live.” - Irish Proverb';
$Quote[129]='“We\'re here for a reason. I believe a bit of the reason is to throw little torches out to lead people through the dark.” - Whoopi Goldberg';
$Quote[130]='“Who, being loved, is poor?” - Oscar Wilde';
$Quote[131]='“Love makes your soul crawl out from its hiding place.” - Zora Neale Hurst';
$Quote[132]='“Start with what is right rather than what is acceptable. ” - Peter F. Drucker';
$Quote[133]='“The last of the human freedoms is to choose one\'s attitudes.” - Viktor Frankl';
$Quote[134]='“I will offer a choice, not an echo.” - Barry M. Goldwater';
$Quote[135]='“Look at what you\'ve got and make the best of it. It is better to light a candle than to curse the darkness.” - Proverb';
$Quote[136]='“Adopt the pace of nature: her secret is patience.” - Ralph Waldo Emerson';
$Quote[137]='"He who destroys a good book, kills reason itself" - John Milton';
$Quote[138]='“The greatest power is often simple patience.” - E. Joseph Cossman';
$Quote[139]='“Perhaps the most important thing we can undertake toward the reduction of fear is to make it easier for people to accept themselves, to like themselves.” - Bonaro W. Overstreet';
$Quote[140]='“Few things can help an individual more than to place responsibility on him, and to let him know that you trust him. ” - Booker T. Washington';
$Quote[141]='“Those who mind don\'t matter, and those who matter don\'t mind.” - Bernard M. Baruch';
$Quote[142]='"Life itself is only a vision, a dream. Nothing exists. Just empty space and you. And you, are but a thought." - Satan';
$Quote[143]='“Action springs not from thought, but from a readiness for responsibility.” - Dietrich Bonhoeffer';
$Quote[144]='“Put your ear down close to your soul and listen hard.” - Anne Sexton';
$Quote[145]='"Quoth the raven, nevermore." - Edgar Allen Poe';
$Quote[146]='“Man is so made that when anything fires his soul, impossibilities vanish.” - Jean de La Fontaine';
$Quote[147]='“The heart may be broken, and the soul remain unshaken.” - Napoleon Bonaparte';
$Quote[148]='"I contend that we are both atheists. I just believe in one fewer god than you do. When you understand why you dismiss all the other possible gods, you will understand why I dismiss yours." - Stephen Roberts';
$Quote[149]='“There are souls in this world which have the gift of finding joy everywhere and of leaving it behind them when they go.” - Fredrick Faber';
$Quote[150]='“It is common sense to take a method and try it. If it fails, admit it frankly and try another. But above all, try something.” - Franklin D. Roosevelt';
$Quote[151]='“If you think you are too small to be effective, you have never been in the dark with a mosquito.” - Unknown';
$Quote[152]='“Just go out there and do what you\'ve got to do.” - Martina Navrátilová';
$Quote[153]='“Nothing is at last sacred but the integrity of your own mind.” - Ralph Waldo Emerson';
$Quote[154]='"Freedom is not a gift from Heaven. One must fight for it every day." - Simon Wiesenthal';
$Quote[155]='“Wisdom is knowing what to do next; virtue is doing it.” - David Star Jordan';
$Quote[156]='“No amount of ability is of the slightest avail without honor.” - Andrew Carnegie';
$Quote[157]='“Better keep yourself clean and bright. You are the window through which you must see the world.” - George Bernard Shaw';
$Quote[158]='“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.” - Charles Swindoll';
$Quote[159]='“Good actions give strength to ourselves and inspire good actions in others.” - Plato';
$Quote[160]='“Just don\'t give up trying to do what you really want to do. Where there\'s love and inspiration, I don\'t think you can go wrong.” - Ella Jane Fitzgerald';
$Quote[161]='“If you tell a big enough lie and tell it frequently enough, it will be believed.” - Adolf Hitler';
$Quote[162]='“Nothing is so strong as gentleness. Nothing is so gentle as real strength.” - Saint Francis de Sales';
$Quote[163]='“The real man smiles in trouble, gathers strength from distress, and grows brave by reflection.” - Thomas Paine';
$Quote[164]='“We either make ourselves miserable or we make ourselves strong. The amount of work is the same.” - Carlos Casteneda';
$Quote[165]='“Were it not for hope the heart would break.” - Scottish Proverb';
$Quote[166]='“No winter lasts forever; no spring skips it\'s turn.” - Hal borland';
$Quote[167]='“Do not compare yourself to others. If you do so, you are insulting yourself.” - Adolf Hitler';
$Quote[168]='“Once you choose hope, anything\'s possible.” - Christopher Reeve';
$Quote[169]='“We must accept finite disappointment, but we must never lose infinite hope.” - Martin Luther King Jr.';
$Quote[170]='“Strive to be first: first to nod, first to smile, first to compliment, and first to forgive.” - Anonymous';
$Quote[171]='“Work is either fun or drudgery. It depends on your attitude. I like fun.” - Colleen C. Barrett';
$Quote[172]='"A fool learns by his mistakes, a wise man learns from the mistakes of others." - The Librarian';
$Quote[173]='“ \'Stay\' is a charming word in a friend\'s vocabulary.” - Louisa May Alcott';
$Quote[174]='“We are all in the same boat in a stormy sea, and we owe each other a terrible loyalty.” - G. K. Chesterton';
$Quote[175]='“The best things in life are never rationed. Friendship, loyalty, love, do not require coupons.” - George T. Hewitt';
$Quote[176]='“It is better to be faithful than famous.” - Theodore Roosevelt';
$Quote[177]='“The test of courage comes when we are in the minority. The test of tolerance comes when we are in the majority.” - Ralph W. Sockman';
$Quote[178]='“Trust thyself: every heart vibrates to that iron string.” - Ralph Waldo Emerson';
$Quote[179]='“Life has meaning only if one barters it day by day for something other than itself.” - Antoine de Sainte-Exupery';
$Quote[180]='“No one is more cherished in this world than someone who lightens the burden of another.” - Unknown';
$Quote[181]='“I can live for two months on a good compliment.” - Mark Twain';
$Quote[182]='“No one\'s head aches when he is comforting another.” - Indian Proverb';
$Quote[183]='“Appreciation...acknowledges the presence of good wherever you shine the light of your thankful thoughts.” - Alan Cohen';
$Quote[184]='“The best way to find yourself is to lose yourself in the service of others.” - Mohandas Karamchand Gandhi';
$Quote[185]='“Be a good listener. Your ears will never get you in trouble.” - Frank Tyger';
$Quote[186]='“Dreams come in a size too big so that we may grow into them.” - Josie Bisset';
$Quote[187]='“And the day came when the risk to remain tight in a bud was more painful than the risk it took to blossom.” - Anais Nin';
$Quote[188]='“Gracefulness has been defined to be the outward expression of the inward harmony of the soul.” - William Hazlitt';
$Quote[189]='“What ever beauty may be, it has for its basis order, and for its essence unity.” - Father Andre';
$Quote[190]='“Example has more followers than reason.” - Christian Nestell Bovee';
$Quote[191]='“A mind is a fire to be kindled, not a vessel to be filled.” - Plutarch';
$Quote[192]='“To be good is noble, but to teach others how to be good is nobler--and less trouble.” - Mark Twain';
$Quote[193]='“When there is no enemy within, the enemies outside cannot hurt you.” - African Proverb';
$Quote[194]='“We learn more by looking for the answer to a question and not finding it than we do from learning the answer itself.” - Lloyd Alexander';
$Quote[195]='“When spider webs unite they can tie up a lion.” - African Proverb';
$Quote[196]='“I am a part of all that I have met.” - Alfred Tennyson, 1st Baron Tennyson';
$Quote[197]='“Only a life lived for others is worth living.” - Albert Einstein';
$Quote[198]='“The wise man belongs to all countries, for the home of a great soul is the whole world.” - Democritus';
$Quote[199]='“Diversity is the one true thing we all have in common. Celebrate it every day.” - Unknown';
$Quote[200]='“As man draws nearer to the stars, why should he not also draw nearer to his neighbor?” - Lyndon B. Johnson';
$Quote[201]='“All doors open to courtesy. ” - Dr. Thomas Fuller';
$Quote[202]='“Character is the total of thousands of small daily strivings to live up to the best that is in us.” - A. G. Trudeau';
$Quote[203]='“With courage you will dare to take risks, have the strength to be compassionate, and the wisdom to be humble. Courage is the foundation of integrity.” - Keshavan Nair';
$Quote[204]='“No steam or gas drives anything until it is confined. No life ever grows great until it is focused, dedicated, disciplined.” - Harry Emerson Fosdick';
$Quote[205]='“Love yourself, accept yourself, forgive yourself, and be good to yourself, because without you the rest of us are without a source of many wonderful things.” - Dr. Leo Buscaglia';
$Quote[206]='“To love means loving the unlovable. To forgive means pardoning the unpardonable. Faith means believing the unbelievable. Hope means hoping when everything seems hopeless.” - G. K. Chesterton';
$Quote[207]='“When work, commitment, and pleasure all become one and you reach that deep well where passion lives, nothing is impossible.” - Nancy Coey';
$Quote[208]='“It was character that got us out of bed, commitment that moved us into action, and discipline that enabled us to follow through.” - Zig Ziglar';
$Quote[209]='“Reach high, for stars lie hidden in your soul. Dream deep, for every dream precedes the goal.” - Pamela Vaull Starr';
$Quote[210]='“The road of life twists and turns and no two directions are ever the same. Yet our lessons come from the journey, not the destination.” - Don Williams Jr.';
$Quote[211]='“Humility leads to strength and not to weakness. It is the highest form of self-respect to admit mistakes and to make amends for them.” - John J. McCloy';
$Quote[212]='“Sense shines with a double luster when it is set in humility. An able and yet humble man is a jewel worth a kingdom.” - William Penn';
$Quote[213]='“Dream your dream. Follow your heart. Imagine. Listen to the wind. Drink sunsets. Be free. Let the wonder never cease. Believe. Wish on EVERY star. Create adventure. Be Kind.” - Debbie Coulter';
$Quote[214]='Quote goes here';
$Quote[215]='Quote goes here';
$Quote[216]='Quote goes here';
$Quote[217]='Quote goes here';
$Quote[218]='Quote goes here';
$Quote[219]='Quote goes here';
$Quote[220]='Quote goes here';
$Quote[221]='Quote goes here';
$Quote[222]='Quote goes here';
$Quote[223]='Quote goes here';
$Quote[224]='Quote goes here';
$Quote[225]='Quote goes here';
$Quote[226]='Quote goes here';
$Quote[227]='Quote goes here';
$Quote[228]='Quote goes here';
$Quote[229]='Quote goes here';
$Quote[230]='Quote goes here';
$Quote[231]='Quote goes here';
$Quote[232]='Quote goes here';
$Quote[233]='Quote goes here';
$Quote[234]='Quote goes here';
$Quote[235]='Quote goes here';
$Quote[236]='Quote goes here';
$Quote[237]='Quote goes here';
$Quote[238]='Quote goes here';
$Quote[239]='Quote goes here';
$Quote[240]='Quote goes here';
$Quote[241]='Quote goes here';
$Quote[242]='Quote goes here';
$Quote[243]='Quote goes here';
$Quote[244]='Quote goes here';
$Quote[245]='Quote goes here';
$Quote[246]='Quote goes here';
$Quote[247]='Quote goes here';
$Quote[248]='Quote goes here';
$Quote[249]='Quote goes here';
$Quote[250]='Quote goes here';
$Quote[251]='Quote goes here';
$Quote[252]='Quote goes here';
$Quote[253]='Quote goes here';
$Quote[254]='Quote goes here';
$Quote[255]='Quote goes here';
$Quote[256]='Quote goes here';
$Quote[257]='Quote goes here';
$Quote[258]='Quote goes here';
$Quote[259]='Quote goes here';
$Quote[260]='Quote goes here';
$Quote[261]='Quote goes here';
$Quote[262]='Quote goes here';
$Quote[263]='Quote goes here';
$Quote[264]='Quote goes here';
$Quote[265]='Quote goes here';
$Quote[266]='Quote goes here';
$Quote[267]='Quote goes here';
$Quote[268]='Quote goes here';
$Quote[269]='Quote goes here';
$Quote[270]='Quote goes here';
$Quote[271]='Quote goes here';
$Quote[272]='Quote goes here';
$Quote[273]='Quote goes here';
$Quote[274]='Quote goes here';
$Quote[275]='Quote goes here';
$Quote[276]='Quote goes here';
$Quote[277]='Quote goes here';
$Quote[278]='Quote goes here';
$Quote[279]='Quote goes here';
$Quote[280]='Quote goes here';
$Quote[281]='Quote goes here';
$Quote[282]='Quote goes here';
$Quote[283]='Quote goes here';
$Quote[284]='Quote goes here';
$Quote[285]='Quote goes here';
$Quote[286]='Quote goes here';
$Quote[287]='Quote goes here';
$Quote[288]='Quote goes here';
$Quote[289]='Quote goes here';
$Quote[290]='Quote goes here';
$Quote[291]='Quote goes here';
$Quote[292]='Quote goes here';
$Quote[293]='Quote goes here';
$Quote[294]='Quote goes here';
$Quote[295]='Quote goes here';
$Quote[296]='Quote goes here';
$Quote[297]='Quote goes here';
$Quote[298]='Quote goes here';
$Quote[299]='Quote goes here';
$Quote[300]='Quote goes here';
$Quote[301]='Quote goes here'
$Quote[302]='Quote goes here'
$Quote[303]='Quote goes here';
$Quote[304]='Quote goes here';
$Quote[305]='Quote goes here';
$Quote[306]='Quote goes here';
$Quote[307]='Quote goes here';
$Quote[308]='Quote goes here';
$Quote[309]='Quote goes here';
$Quote[310]='Quote goes here';
$Quote[311]='Quote goes here';
$Quote[312]='Quote goes here';
$Quote[313]='Quote goes here';
$Quote[314]='Quote goes here';
$Quote[315]='Quote goes here';
$Quote[316]='Quote goes here';
$Quote[317]='Quote goes here';
$Quote[318]='Quote goes here';
$Quote[319]='Quote goes here';
$Quote[320]='Quote goes here';
$Quote[321]='Quote goes here';
$Quote[322]='Quote goes here';
$Quote[323]='Quote goes here';
$Quote[324]='Quote goes here';
$Quote[325]='Quote goes here';
$Quote[326]='Quote goes here';
$Quote[327]='Quote goes here';
$Quote[328]='Quote goes here';
$Quote[329]='Quote goes here';
$Quote[330]='Quote goes here';
$Quote[331]='Quote goes here';
$Quote[332]='Quote goes here';
$Quote[333]='Quote goes here';
$Quote[334]='Quote goes here';
$Quote[335]='Quote goes here';
$Quote[336]='Quote goes here';
$Quote[337]='Quote goes here';
$Quote[338]='Quote goes here';
$Quote[339]='Quote goes here';
$Quote[340]='Quote goes here';
$Quote[341]='Quote goes here';
$Quote[342]='Quote goes here';
$Quote[343]='Quote goes here';
$Quote[344]='Quote goes here';
$Quote[345]='Quote goes here';
$Quote[346]='Quote goes here';
$Quote[347]='Quote goes here';
$Quote[348]='Quote goes here';
$Quote[349]='Quote goes here';
$Quote[350]='Quote goes here';
$Quote[351]='Quote goes here';
$Quote[352]='Quote goes here';
$Quote[353]='Quote goes here';
$Quote[354]='Quote goes here';
$Quote[355]='Quote goes here';
$Quote[356]='Quote goes here';
$Quote[357]='Quote goes here';
$Quote[358]='Quote goes here';
$Quote[359]='Quote goes here';
$Quote[360]='Quote goes here';
$Quote[361]='Quote goes here';
$Quote[362]='Quote goes here';
$Quote[363]='Quote goes here';
$Quote[364]='Quote goes here';
$Quote[365]='Quote goes here';

echo 'Quote Of The Day #' . $today . '<br>';
echo $Quote[$today];
?>
Edited by JesseToxik
Link to comment
Share on other sites

  • Solution

And what are you getting? Errors or not what you expect?

 

I see at least one thing wrong on the basis of these two lines:

$today = date("z") + 1;

$Quote[0]='Quote goes here';

The 'z' will return "The day of the year (starting from 0) 0 through 365". And you are adding 1 to that value. So, $today will be a value from 1 to 366. But, your array has indexes of 0 to 365. Remove the +1.

 

EDIT: Here's another problem

$Quote[100]='Quote goes here';
$Quote[101]='Quote goes here'
$Quote[102]='Quote goes here'
$Quote[103]='Quote goes here';

Missing the semicolon at the end of those two lines

 

Edit #2: and another two lines missing semi-colons

 

$Quote[300]='Quote goes here';
$Quote[301]='Quote goes here'
$Quote[302]='Quote goes here'
$Quote[303]='Quote goes here';

 

Funny how I get errors such as this before I made those corrections.

 

 

Parse error: syntax error, unexpected T_VARIABLE in D:\xampp\htdocs\test.php on line 106

Wonder what that line number is telling me.

Edited by Psycho
Link to comment
Share on other sites

Works fine now lol

Bryce I caught my error of not calling array(). Shouldn't you be on Vampirefreaks anyway :P

 

Sadly I didn't get any errors.

Got onto a new host today and all it did was throw a error 500 at me without any debugging.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.