aquilina Posted February 27, 2011 Share Posted February 27, 2011 anyone can guide me why i cann't run some of php files using wamp server? I only can run some of php file using wamp server. This is example the php code that i cannt run using wamp server but i tested using apache its works.. <?$d = date(D);if ($d == 'Mon'){ echo "Today is Monday.Yay!!";}else if ($d == 'Tues'){ echo "Today is Tuesday.Yay!!";}else if ($d == 'Wed'){ echo "Today is Wednesday.Yay!!";}else if ($d == 'Thurs'){ echo "Today is Thursday.Yay!!";}else if ($d == 'Fri'){ echo "Today is Friday.Yay!!";}else if ($d == 'Sat'){ echo "Today is Saturday.Yay!!";}else if ($d == 'Sun'){ echo "Today is Sunday.Yay!!";}?> Link to comment Share on other sites More sharing options...
jeffman Posted February 27, 2011 Share Posted February 27, 2011 Maybe your WAMP is not configured to recognize short tags? Try opening the script with <?php Link to comment Share on other sites More sharing options...
thescientist Posted February 27, 2011 Share Posted February 27, 2011 I'm not sure what you mean that it worked on Apache but not in PHP. If PHP is installed on a (Apache) server, then it should work. The simple test if to run a php file with this code in it somewhere in webroot. <?phpphpinfo();?> If you get an output of information, then you know you have PHP installed and running on your server.as to your code, the first thing I notice is your opening php tag. You have <? it should be <?php also, the date function when, passed 'D', only returns a three character representation of the date.http://www.w3schools.com/PHP/func_date_date.aspSomething to consider for Tuesday and Thursday. You may want to consider a simpler implementation: <?php$days = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');$daysIndex = date('w');echo 'Today is ' . $days[$daysIndex] . '.Yay!!';?> just make an array for all the days, and then just get the index representation returned by passing 'w' to the date object instead.edit: fixed an undefined variable error Link to comment Share on other sites More sharing options...
aquilina Posted February 27, 2011 Author Share Posted February 27, 2011 Yea i tried to put <?php at beginning its works but its show me this result Notice: Use of undefined constant D - assumed 'D' in C:\wamp\www\a.php on line 2Today is Sunday.Yay!!Thescientist, i know the wampserver contain apache function, but theres a software that called Apache Web server that run the php.. its not work when i using wampserver, but when i using Apache Web Server to run it, its works without put <?php Link to comment Share on other sites More sharing options...
thescientist Posted February 27, 2011 Share Posted February 27, 2011 that's an error with your code, not PHP or Apache. You need to pass a string to the date function. like in my example: $dayIndex = date('w'); Link to comment Share on other sites More sharing options...
aquilina Posted February 27, 2011 Author Share Posted February 27, 2011 that's an error with your code, not PHP or Apache. You need to pass a string to the date function. like in my example:$dayIndex = date('w'); The code that u give me give me this resultNotice: Undefined variable: daysIndex in C:\wamp\www\a.php on line 5Notice: Undefined index: in C:\wamp\www\a.php on line 5Today is .Yay!! Link to comment Share on other sites More sharing options...
boen_robot Posted February 27, 2011 Share Posted February 27, 2011 You shold really learn to read the error messages. They say so much... Notice: Undefined variable: daysIndex in C:\wamp\www\a.php on line 5Compare that to$dayIndex = date('w');echo 'Today is ' . $days[$daysIndex] . '.Yay!!';thescientist simply made a spelling mistake, that's all. Fix it in one way or the other. Link to comment Share on other sites More sharing options...
thescientist Posted February 27, 2011 Share Posted February 27, 2011 You shold really learn to read the error messages. They say so much...Compare that tothescientist simply made a spelling mistake, that's all. Fix it in one way or the other.fixed, and edited in the the post. my bad. Link to comment Share on other sites More sharing options...
aquilina Posted February 27, 2011 Author Share Posted February 27, 2011 oK thankx scientist for the help.. sorry coz i'm still new in php and very careless wit a simple mistake Link to comment Share on other sites More sharing options...
Synook Posted February 28, 2011 Share Posted February 28, 2011 Comment - "WampServer" is not server software by itself, but a package of several different components - "WAMP" stands for "Windows Apache MySQL PHP". So when you use WampServer, you actually are using Apache to serve the files. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.