Trouble with some code  help please

i need help with this program i have to do a webclient in java i will put here the instructions that were given to me and then the work i have been doing so you can have an idea of what i'm doing any help you give me i will be very thankful thanks.
Here are the instructions
The class WebClient will represent a simple web client. This class must provide the following functions:
1. connect to a web page using a URL
2. obtain or get the response from a server
This funcionality will be provided by the public interface of the class:
- WebClient( )
Creates a new object of the class
- void setURL(String url)
Used to indicate the URL of the web page
- String getResponse()
Gets the response of the server to the page who's URL was indicated(Example of a response: HTTP/1.0 200 OK)
You have to implement the following:
1. The class WebClient with an public interface that Includes the methods specified upwards, in a file called WebClient.java
2.A class WebClientTester, in a file called WebClientTester.java, with a main program that minimun have to:
a) Create a instance of WebClient
b) Using 3 valid URL's
- Invoque setURL to indicate the URL of the server
- Invoque getResponse to get the response of the server
- display in the console the response of the server
c) Using 3 invalid URL's (this is the correct server but the page does not are on the server)
- Invoque setURL to indicate the URL of the server
- Invoque getResponse to get the response of the server
- display in the console the response of the server
As a tip they give me that i can use the clases HttpURLConnection and URL to implement WebClient. It is recommended to save the URL in an instance field of WebClient.
Those are the instructions now i will write here what i have do until now
This is the WebClient Class:
public class WebClient
     public String Wecli;
     public WebClient()
          Wecli = new String();
     public void setURL(String url)
     /** need code here */     
     public String getResponse()
     /** need code here */     
     public void display()
          System.out.println(Wecli);
what i need there is the methods constructors or whatever are so that setURL and getResponse work and do what are suposed to do.
Here is The WebClientTester class
public class WebClientTester
     public static void main(String[] args)
          WebClient wbcl = new WebClient();
          wbcl.setURL(http://www.nba.com);
          wbcl.getResponse();
          wbcl.display();
          wbcl.setURL(http://www.mlb.com);
          wbcl.getResponse();
          wbcl.display();
          wbcl.setURL(http://www.msn.com);
          wbcl.getResponse();
          wbcl.display();
     wbcl.setURL(http://www.nba.com/baseball.html);
          wbcl.getResponse();
          wbcl.display();
     wbcl.setURL(http://www.mlb.com/basketball.html);
          wbcl.getResponse();
          wbcl.display();
     wbcl.setURL(http://www.msn.com/practice.html);
          wbcl.getResponse();
          wbcl.display();
that is basically what i think i need so that the program works any other help you can give me will be very useful thanks for reding it and give your opinions.

Those are the instructions now i will write here what i have do until nowLooks like you've posted your homework instructions, done less than the bare minimum to make it look like you thought about this problem, and now you want strangers to help you cheat by giving you the code that does the work so you can hand it in as your own.
%

Similar Messages

  • Need some code help please

    I am trying to make a sun and planet with the planet orbiting the sun. It is all working but the complier is having a problem with the instance variable _ball in the programs.  Can anyone help me fix this, I think I'm almost there.
    public class MovingBall extends javax.swing.JPanel
        int X0 = 100, Y0 = 100;
        double X2, Y2;
        double r = 10;
        double a = 0;
        double da = .04;
        double ecc = 1;
        double TWOPI = 2 * Math.PI;
        private javax.swing.JPanel _panel;
        public MovingBall (java.awt.Color aColor, javax.swing.JPanel aPanel)
         super();
         _panel = aPanel;
         X2 = X0 + r * Math.cos(a);
         Y2 = Y0 + r * Math.sin(a);
         //this.setLocation(X2, Y2);
        public void move()
         a = a + da;
         a = a % TWOPI;
         X2 = X0 + r * ecc * Math.sin(a);
         Y2 = Y0 + r * ecc * Math.sin(a);
         //this.setLocation (X2, Y2);
        public boolean inFront()
         return (a <= Math.PI);
        public void SetCircle(int x, int y)
         X0 = x;
         Y0 = y;
         //ecc = 1.0 - (double)pct/100;
    public class MovingBallPanel extends javax.swing.JPanel implements Mover, Controller
        private final int INIT_X = 250;
        private final int INIT_Y = 200;
        private SmartEllipse _sun;
        private Sky _sky;
        private final int SUN_DIAMETER = 60;
        //private MovingBall _ball;
        private final int PLANET_DIAMETER = 35;
        private final int ORBIT_DIAMETER = 185;
        int _da = 1;
        int _ecc = 1;
        private final int INTERVAL = 100;
        private MoveTimer _timer;
        public MovingBallPanel()
         super();
         this.setBackground(java.awt.Color.BLACK);
         _sun = new SmartEllipse(java.awt.Color.YELLOW);
         _sun.setSize(SUN_DIAMETER, SUN_DIAMETER);
         _sun.setLocation(INIT_X - SUN_DIAMETER/2, INIT_Y - SUN_DIAMETER/2);
         //_ball = new MovingBall();
         //_ball.setCenter((INIT_X - PLANET_DIAMETER)/2, (INIT_Y - PLANET_DIAMETER)/2);
         //_ball.setAngleIncrement(_da);
         _sky = new Sky();
         _timer = new MoveTimer(INTERVAL, this);
         _timer.start();
        public void move()
            //_ball.move();
            this.repaint();
        public void go (boolean g)
         //if (g) _ball.setAngleIncrement(_da);
            //else _ball.setAngleIncrement(0);
        public void setSpeed(int degrees)
         _da = 2 * degrees;
         //_ball.setAngleIncrement(_da);
        public void setEccentricity(int pct)
         _ecc = pct;
         //_ball.setEccentricity(_ecc);
        public void paintComponent(java.awt.Graphics aBrush)
         super.paintComponent (aBrush);
         java.awt.Graphics2D betterBrush = (java.awt.Graphics2D) aBrush;
         _sky.paintSky(betterBrush);
         _sun.draw(betterBrush);
         _sun.fill(betterBrush);
         //_ball.fill(betterBrush);
    }I think only those classes affect the problem. Thanks.

    They all complie separately, but when I complie PlanetApp which creates the frame it has the problem. It says it can't find the symbol for ball for all the methods that I call with it, such as ball.setEccentricity(...) or _ball.fill(...).  Here is the PlanetApp class.  Thanks.
    public class PlanetApp extends javax.swing.JFrame
        ControlPanel _controlPanel;
        MovingBallPanel _movingBallPanel;
        public PlanetApp (String title)
         super(title);
         this.setSize(600,500);
         this.setBackground(java.awt.Color.BLACK);
         this.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
         _movingBallPanel = new MovingBallPanel();
         _controlPanel = new ControlPanel(_movingBallPanel);
         this.add(_movingBallPanel, java.awt.BorderLayout.CENTER);
         this.add(_controlPanel, java.awt.BorderLayout.SOUTH);
         this.setVisible(true);
        public static void main (String [] args)
         PlanetApp app =  new PlanetApp("Lab 7");
    }

  • Having trouble with quicktime. Help please.

    A while ago, maybe a few months actually. My quicktime stopped working so i uninstalled it and installed it again. Now whenever I go to a website where I need quicktime to see videos, I only hear the audio (e.g Apple websites, guided tour videos, audio only). What can I do to fix this problem.

    These forums can somtimes be helpful, but after a lot of reading in this case, I'm stumped.
    No help starting, then quitting GarageBand, no help setting MIDI audio output to 44100 Hz (it was already there), no help reinstalling QT 7.0.4, no help rolling back to QT 7.0.1, no help shutting down all other applications when running QT. OS is current, with no more available updates. The video I edited on this same computer using Quicktime and posted on putfile plays fine on my (gasp) older PC running Windows QT 7.0.4.
    As a loyal Macintosh owner since 1984 (my family currently has 7 working Macs, 3 iPods and 1 PC), I have the sinking feeling Apple seems to be becoming less unique and more microsoft like over time. While MS isn't up to the level of Apple yet, the gap seems to be closing. I don't want to know how to change my audio settings, repair permissions or do anything not directly related to the task at hand. I'm getting tired of paying for "upgrades" that aren't, including the new iLife suite and the QT 7 pro key I recently bought.
    How do we report this issue? I encourage everyone who is having problems with Quicktime videos stuttering, dropping video or audio to report this so that Apple will be made aware and held responsible.
    PowerBook G4 1.33 GHz   Mac OS X (10.4.5)   1.25 GB Ram

  • Trouble with songs. need help please!

    alright, so here's my problem.
    last week i tried to put some songs from a cd on my ipod (video 30g). when they were in my library they worked fine but now on my ipod they are not working. if i click on them nothing is happening.
    i tried to delete them from my ipod but everytime i select them and hit delete, my itunes (latest version) freeze. i did erase them once before it froze but when i looked on my ipod they were still there. also, everytime i tried to put some new songs (not from the same cd) on my ipod, they go fine in my library but when i transfer them, it says synchronizing but does nothing.
    i don't know what to do and i really hope i don't have to restore and lose everything cause i lost everything last week as my hard drive died (i don't know if it can be related tho)
    help is needed!!!
    p.s. sorry for my english :S

    thank you but i did tried the basics. after posting my question here i tried a couple of thing and realized that all i could do was a restore. so i tried a restore and when i try it, my itunes doesnt do a thing and stop working. also, the weird thing is, when i look in my cache files for the ipod, no songs is in the folders where they are supposed to be, and when i try to play some songs it just show all the information but skip the songs quickly. so it seems like the information and everythng is still in the ipod but there's no songs in it anymore. so the only thing i'm looking for is for a way to restore the ipod to its original settings without using itunes...

  • Trouble with iTouch, Somebody help please ^^

    Ok, a friend of mine won a iTouch yestarday that his uncle bought in the U.S.A two weeks ago, but today when we tried to put music and other stuff on it, it just load until the half and stoped, after that the itunes stop working and the iTouch was eject automatically.
    I went to his home, trying to help 'cuz i have one but nothing that i did worked and he called me saying that now, not even the iTouch is reconized by the itunes.
    Please, if anyone can help i would be grateful^^
    PS: Sorry about the english, is not that bad but still not perfect :P

    OK, it was not answered but that's all right, thanks anyway, i don't know how but a frind of mine fixed it so that's working now.
    Thanks again :P

  • Major trouble with WRT54G. Help please?

    I was trying to open my NAT for better connection with my friends over Xbox Live, so I went to the Live Chat for help with this and I got it open. Maybe a month later it says my NAT is at "Moderate" settings again so I asked what could be the problem and the person I was in chat with suggested I upgrade the routers firmware and then try to open the NAT so I upgraded and then did everything that I was told to do to open it again and now I cant even get on the internet with it. Every page or URL I type in redirects me to my ISP's "hotspot" page. Can anyone help me???

    In that case your modem has to be Updated/re-configured.

  • What's wrong with my code? please help....

    when display button is clicked it must diplay the remarks but it didn't happen...
    what's wrong with my code? please help
    here is my code.....
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    public class Area extends Applet implements ItemListener,ActionListener
         {Label arlbl = new Label("AREA");
          Choice archc = new Choice();
          Label extlbl = new Label("EXPENDITURE TYPE");
          CheckboxGroup extchk = new CheckboxGroup();
              Checkbox fchk = new Checkbox("FOOD",extchk,true);
              Checkbox schk = new Checkbox("SHELTER",extchk,false);
              Checkbox echk = new Checkbox("EDUCATION",extchk,false);
              Checkbox uchk = new Checkbox("UTILITIES",extchk,false);
          Label exalbl = new Label("EXPENDITURE AMOUNT");
          TextField exatf = new TextField("",20);
          Label remlbl = new Label("REMARKS");
          TextField remtf = new TextField("",30);
          Button disbtn = new Button("DISPLAY");
          Button resbtn = new Button("RESET");
          String display;
          public void init()
              {add(arlbl);
               archc.add("MANILA");
               archc.add("MAKATI");
               archc.add("QUEZON");
               archc.add("PASAY");
               add(archc);
               archc.addItemListener(this);
               add(extlbl);
               add(fchk);
               fchk.addItemListener(this);
               add(schk);
               schk.addItemListener(this);     
               add(echk);
               echk.addItemListener(this);
               add(uchk);
               uchk.addItemListener(this);
               add(exalbl);
               add(exatf);
               add(remlbl);
               add(remtf);
               add(disbtn);
               disbtn.addActionListener(this);
               add(resbtn);
               resbtn.addActionListener(this);
         public void itemStateChanged(ItemEvent ex)
              {int n = archc.getSelectedIndex();
               if(n==0)
                   {if(fchk.getState())
                         {exatf.setText("10000.00");
                         display = archc.getSelectedItem();
                   if(schk.getState())
                        {exatf.setText("15000.00");
                        display = archc.getSelectedItem();
                   if(echk.getState())
                        {exatf.setText("24000.00");
                        display = archc.getSelectedItem();
                   if(uchk.getState())
                        {exatf.setText("8500.00");
                        display = archc.getSelectedItem();
              if(n==1)
                   {if(fchk.getState())
                        {exatf.setText("5000.00");
                        display = archc.getSelectedItem();
                   if(schk.getState())
                        {exatf.setText("11000.00");
                        display = archc.getSelectedItem();
                   if(echk.getState())
                        {exatf.setText("7500.00");
                        display = archc.getSelectedItem();
                   if(uchk.getState())
                        {exatf.setText("24000.00");
                        display = archc.getSelectedItem();
              if(n==2)
                   {if(fchk.getState())
                        {exatf.setText("13000.00");
                        display = archc.getSelectedItem();
                   if(schk.getState())
                        {exatf.setText("7000.00");
                        display = archc.getSelectedItem();
                   if(echk.getState())
                        {exatf.setText("27000.00");
                        display = archc.getSelectedItem();
                   if(uchk.getState())
                        {exatf.setText("6000.00");
                        display = archc.getSelectedItem();
              if(n==3)
                   {if(fchk.getState())
                        {exatf.setText("6000.00");
                        display = archc.getSelectedItem();
                   if(schk.getState())
                        {exatf.setText("9000.00");
                        display = archc.getSelectedItem();
                   if(echk.getState())
                        {exatf.setText("15000.00");
                        display = archc.getSelectedItem();
                   if(uchk.getState())
                        {exatf.setText("19000.00");
                        display = archc.getSelectedItem();
         public void actionPerformed(ActionEvent e)
              {if(e.getSource() == disbtn)
                    {String amtstr = exatf.getText();
                     int amt = Integer.parseInt(amtstr);
                        {if(amt > 8000)
                             {remtf.setText(display + " IS ABOVE BUDGET");
                        else
                             {remtf.setText(display + " IS BELOW BUDGET");
              if(e.getSource() == resbtn)
                   {archc.select(0);
                   fchk.setState(true);
                   schk.setState(false);
                   echk.setState(false);
                   uchk.setState(false);
                   exatf.setText("");
                   remtf.setText("");
    Edited by: lovely23 on Feb 28, 2009 11:24 PM

    Edit: thanks for cross-posting this question on another forum. I now see that I wasted my time trying to study your code in the java-forums to help you with an answer that had already been answered elsewhere (here). Do you realize that we are volunteers, that our time is as valuable as yours? Apparently not. Cross-post again and many here will not help you again. I know that I won't.

  • An error encounter on test devise (real devise) i.e "apple mach -o linker error linker command failed with exit code 1", please any body help me to solve the problem

    Hello, I am using tesseract api in my app, which run perfectly on simulator but on test devise (real devise) it is showing an error i.e "apple mach -o linker error linker command failed with exit code 1", please any body help me to solve the problem

    if you can't compile the webutil.pll in your forms developer you need to set the forms_builder_classpath in you windows registry. You have to add the frmwebutil.jar,jacob.jar to the registry key. The configuration files you mention are for running the forms.

  • Can anyone tell me how to get rid of tlb search? it unfortunately entered into my mac. Whenever I use safari, a pop-up window opens with some ads. Please help me to find a way to remove this malware.

    Can anyone tell me how to get rid of tlb search? It unfortunately entered into my mac. Whenever I use safari, a pop-up window opens with some ads. Please help me to find a way to remove this malware.

    You installed the "DownLite" trojan, perhaps under a different name. Remove it as follows.
    Malware is constantly changing to get around the defenses against it. The instructions in this comment are valid as of now, as far as I know. They won't necessarily be valid in the future. Anyone finding this comment a few days or more after it was posted should look for more recent discussions or start a new one.
    Back up all data.
    Triple-click anywhere in the line below on this page to select it:
    /Library/LaunchAgents/com.vsearch.agent.plist
    Right-click or control-click the line and select
              Services ▹ Reveal in Finder (or just Reveal)
    from the contextual menu.* A folder should open with an item named "VSearch" selected. Drag the selected item to the Trash. You may be prompted for your administrator login password.
    Repeat with each of these lines:
    /Library/LaunchDaemons/com.vsearch.daemon.plist
    /Library/LaunchDaemons/com.vsearch.helper.plist
    /Library/LaunchDaemons/Jack.plist
    Restart the computer and empty the Trash. Then delete the following items in the same way:
    /Library/Application Support/VSearch
    /Library/PrivilegedHelperTools/Jack
    /System/Library/Frameworks/VSearch.framework
    ~/Library/Internet Plug-Ins/ConduitNPAPIPlugin.plugin
    Some of these items may be absent, in which case you'll get a message that the file can't be found. Skip that item and go on to the next one.
    From the Safari menu bar, select
              Safari ▹ Preferences... ▹ Extensions
    Uninstall any extensions you don't know you need, including any that have the word "Spigot" or "Conduit" in the description. If in doubt, uninstall all extensions. Do the equivalent for the Firefox and Chrome browsers, if you use either of those.
    This trojan is distributed on illegal websites that traffic in pirated movies. If you, or anyone else who uses the computer, visit such sites and follow prompts to install software, you can expect much worse to happen in the future.
    You may be wondering why you didn't get a warning from Gatekeeper about installing software from an unknown developer, as you should have. The reason is that the DownLite developer has a codesigning certificate issued by Apple, which causes Gatekeeper to give the installer a pass. Apple could revoke the certificate, but as of this writing, has not done so, even though it's aware of the problem. This failure of oversight is inexcusable and has compromised both Gatekeeper and the Developer ID program. You can't rely on Gatekeeper alone to protect you from harmful software.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination  command-C. In the Finder, select
              Go ▹ Go to Folder...
    from the menu bar and paste into the box that opens by pressing command-V. You won't see what you pasted because a line break is included. Press return.

  • My imessage isn't working when i send messages to people with iphones that have imessage it works with very few people, now it's starting to stop working with those people. help please.

    my imessage doesn't work between my friends and i. i have a new iphone 5. my messages only work with some people. with others imessage doesn't work in the first place and now its starting to stop working with other people help please.
    &amp; yes we all have imessage on.

    Hi there,
    I see that you are having IMessage problems. Some of the problems might be:
    - Your friends IMessage is not activated (you have to activiate it with your apple id)
    - Your IMessage is not activated
    Here is some links to another person`s Imessage problems:
    https://discussions.apple.com/message/17301880#17301880
    https://discussions.apple.com/message/20142285#20142285
    https://discussions.apple.com/message/18988318#18988318
    Hope that helps!

  • After mixing a project i select bounce and burn the disc that is burned plays on any cd player but when i try to burn the wav or mp3 file that was created the resulting disc will only play in a computer this also happens with video projects help please

    after mixing a project i select bounce and burn the disc that is burned plays on any cd player but when i try to burn the wav or mp3 file that was created the resulting disc will only play in a computer this also happens with video projects help please are there any settings i need to alter as it seems the wav or mp3 file i ceated is being converted to a data file somewhere between the folder and disc drive

    Same thing for a movie file.. If you want to play back the movie via a DVD and a DVD player you must create a Movie DVD  and not just burn files to a data DVD... as Data DVDs are just storage devices for files and therefore will only work with computers...
    Movie DVDs are special formats that include things like menus and special file formats.. so they can playback via a DVD Player...
    You will need a 3rd party DVD Burning app like Toast which is what i actually use.... or the more popular DVD Creator app...to create and then burn a Movie DVD that will playback on a DVD Player....
    https://answers.yahoo.com/question/index?qid=20101220205435AA70beb

  • HT1414 I have broken the glass on my ipod touch. I am having trouble with some of my apps opening when I touch the screen. Can the glass be replaced? Will that solve the problem?

    I have broken the glass on my ipod touch. I am having trouble with some of my apps opening when I touch the screen. Can the glass be replaced? Will that solve the problem?

    Very likely yes.
    Apple will exchange your iPod for a refurbished one for $199 if a 64 GB 4G, $99 for the other 4G iPods and $149 for a 5G. They do not fix yours.
    Apple - iPod Repair price              
    A third-party place like the following maybe less. Google for more.
    iPhone Repair, Service & Parts: iPod Touch, iPad, MacBook Pro Screens
    Replace the screen yourself if you are up to it
    iPod Touch Repair – iFixit

  • Q Having trouble with shortcuts in illustrator( Please Help)

    I am having trouble with shortcuts when i exit the program and then try  and use shortcuts it wont work till i go back into edit  and shortcuts menu and click ok to the defaullt setting and i have to keep doing this???? Can  some one please helpme. I am very new to illustrator and i am trying to learn the shortcuts. Also im not very good with technical stuff so  please make answer simple if possible Thanks

    If you are saying that you use the default keyboard shortcuts list, and every time you open Illustrator you can't use any keyboard shortcuts, this must be a bug.
    I'd suggest changing one keyboard shortcut, or as many as you would like, and save it as a new list. Maybe it won't be bugged like the default list.
    If that doesn't work, my only other idea would be re-installing Illustrator. But wait to see what others say here, before trying to re-install.
    Good luck!

  • Help with some code

    I am a complete newbe to programming in general but especially to JAVA. I just started a class to learn but the professor just assigns tasks and the book does not go into actually how to do any of what he asks. Of course this is an online class so there is no real teaching on his part either. What is wrong with my code. I have had to look at code online to try and figure this stuff out. I'm afraid though I havent quite got the jist of what the syntax is for JAVA so my understanding of all of this is very limited.
    here is my code: (the way the forums message box works it seems to word wrap a little different then notepad++ so please bare with the lines that should be "//" and dont show it at the beginning. (example first two lines).
    // My java app that checks to see if a number is even or odd and if it is between 1 and 1000. It also uses the JOptionPane to input and output.
    import javax.swing.JOptionPane;
    import java.io.*;
    import java.lang;
    public class numberChecker
    public static void main(String[] args) throws IOException{
    try{
    JOptionPane.showMessageDialog( "This is a Program to check whether numbers are even\nand if they are between 1 and 1000");
    String name =
    JOptionPane.showInputDialog( null, "Enter in a Number");
    Integer.parseInt( String, name );
    if (name % 2 == 0)
    JOptionPane.showMessageDialog("Is %s even\ntrue");
    } else {
    JOptionPane.showMessageDialog("Is %s even\nfalse.");
    if (name > 0)
    if (name < 1001)
    JOptionPane.showMessageDialog("The number %s between 1 and 1000 is true");
    } else {
    JOptionPane.showMessageDialog("The number %s between 1 and 1000 is false");
    } else {
    JOptionPane.showMessageDialog("The number %s between 1 and 1000 is false");
    JOptionPane.showMessageDialog(null, name);
    catch(NumberFormatException e){
    JOptionPane.showWarningDialog(e.getMessage() + " is not a numeric value.");
    System.exit(0);
    };

    i had updated the code to be this now:
    // My java app that checks to see if a number is even or odd and if it is between 1 and 1000. It also uses the JOptionPane to input and output.
        import javax.swing.JOptionPane;
        import java.io.*;
        import java.lang;
        public class numberChecker
            public static void main(String[] args) throws IOException{
        try{
                JOptionPane.showMessageDialog( "This is a Program to check whether numbers are even\nand if they are between 1 and 1000");
                String name =
                    JOptionPane.showInputDialog( null, "Enter in a Number");
              Int valueToParse =
                    Integer.parseInt( name );
                        if (valueToParse % 2 == 0)
                            JOptionPane.showMessageDialog("Is ",valueToParse," even\ntrue");
                            } else {
                            JOptionPane.showMessageDialog("Is ",valueToParse," even\nfalse.");
                        if (name > 0)
                                if (name < 1001)
                                JOptionPane.showMessageDialog("The number ",valueToParse," between 1 and 1000 is true");
                                } else {
                                JOptionPane.showMessageDialog("The number ",valueToParse," between 1 and 1000 is false");
                            } else {
                            JOptionPane.showMessageDialog("The number ",valueToParse," between 1 and 1000 is false");
                    JOptionPane.showMessageDialog(null, name);
            catch(NumberFormatException e){
            JOptionPane.showWarningDialog(e.getMessage(), " is not a numeric value.");
            System.exit(0);
            };Now i get a bunch of "cant find symbol" errors.

  • Problem with php code. Please help!

    Hello!
    I'm using the following syntax to bring content into my
    websites' layout template:
    Code:
    <?php //check in the root folder first
    if(file_exists('./' . $pagename . '.php'))
    include './' . $pagename . '.php';
    //if it wasn't found in the root folder then check in the
    news folder
    elseif(file_exisits('./news/' . $filename . '.php'))
    include './news/' . $pagename . '.php';
    // if it couldn't be found display message
    else
    echo $pagename . '.php could not be found in either the root
    folder or the news folder!';
    } ?>
    What it's essentially saying is, if you can't find the .php
    file in the _root folder, look for it in the /news/ folder.
    It works perfectly if loading something from the _root folder
    but I get an error if I need to bring something from the /news/
    folder.
    Can anyone see any potential problems with my code?
    Thank you very much and I hope to hear from you.
    Take care,
    Mark

    I've never seen the code written like that before, but I'm
    assuming it's
    legal?
    Perhaps try:
    <?php
    $newsroot = $_SERVER['DOCUMENT_ROOT']."/news";
    if (!file_exists("$pagename.php")) {
    elseif (!file_exists("$newsroot/$pagename.php")) {
    else
    Or the other thing you can try is replacing the elseif
    statement with:
    elseif (!file_exists("news/$pagename.php"))
    If not - I'm sure Gary will be on here soon...
    Shane H
    [email protected]
    http://www.avenuedesigners.com
    =============================================
    Proud GAWDS Member
    http://www.gawds.org/showmember.php?memberid=1495
    Delivering accessible websites to all ...
    =============================================
    "Spindrift" <[email protected]> wrote in
    message
    news:e5mled$272$[email protected]..
    > Hello!
    >
    > I'm using the following syntax to bring content into my
    websites' layout
    > template:
    >
    > Code:
    >
    > <?php //check in the root folder first
    > if(file_exists('./' . $pagename . '.php'))
    > {
    > include './' . $pagename . '.php';
    > }
    > //if it wasn't found in the root folder then check in
    the news folder
    > elseif(file_exisits('./news/' . $filename . '.php'))
    > {
    > include './news/' . $pagename . '.php';
    > }
    > // if it couldn't be found display message
    > else
    > {
    > echo $pagename . '.php could not be found in either the
    root folder or
    > the
    > news folder!';
    > } ?>
    >
    > What it's essentially saying is, if you can't find the
    .php file in the
    > _root
    > folder, look for it in the /news/ folder.
    >
    > It works perfectly if loading something from the _root
    folder but I get an
    > error if I need to bring something from the /news/
    folder.
    >
    > Can anyone see any potential problems with my code?
    >
    > Thank you very much and I hope to hear from you.
    >
    > Take care,
    >
    > Mark
    >

Maybe you are looking for