Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Why doesn't my PHP code work?

  1. #1
    koonoe49 is offline x10Hosting Member koonoe49 is an unknown quantity at this point
    Join Date
    Dec 2010
    Posts
    8

    Arrow Why doesn't my PHP code work?

    I thought we get free PHP here, but all day codes that begin <? or <?PHP have either been warped on the website builder admin panel or the page itself, even when I tried to use the html editor and code paster. It won't even link as a script. Am I doing something wrong?

    I'm just trying to use one PHP code only, rest of my site will probably just be basic HTML.
    Last edited by koonoe49; 01-01-2011 at 11:38 PM.

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,633

    Re: Why doesn't my PHP code work?

    1. Write the code locally and upload via cPanel File Manager or FTP

    or

    2. Use cPanel --> File Manager --> Edit or Code Editor
    Nothing is always absolutely so.

  3. #3
    koonoe49 is offline x10Hosting Member koonoe49 is an unknown quantity at this point
    Join Date
    Dec 2010
    Posts
    8

    Re: Why doesn't my PHP code work?

    Ok, I've tried ALL of those and still no good. A well-written script in the WBAP will either be warped, vanished, have <-- --> inserted ruining it or will read only the HTML compenents and ignore everything else.

    And the WBAP won't read linked PHP script (or at least not from this website since you don't seem to allow linking which I found out testing images, though I'm not sure where I can host a PHP script). I tested the code and it works fine on phpDesigner7.
    Last edited by koonoe49; 01-02-2011 at 03:44 PM.

  4. #4
    Anna's Avatar
    Anna is offline I am just me Anna is a name known to allAnna is a name known to all
    Join Date
    Aug 2007
    Location
    Sweden
    Posts
    6,569

    Re: Why doesn't my PHP code work?

    can you give an example of an url that does not work properly?
    Do you have trouble reaching your site?
    Check here first: News and Announcements


    Don't forget that x10hosting has an irc server as well. Come and join the fun
    server: irc.x10hosting.com, main channel: #x10hosting
    There's a lot helpful users there if need help building your site

  5. #5
    koonoe49 is offline x10Hosting Member koonoe49 is an unknown quantity at this point
    Join Date
    Dec 2010
    Posts
    8

    Re: Why doesn't my PHP code work?

    Just linking an image with <img src=""> works fine, but if it's in a php file it won't work. When I tried that in phpDesigner with an image I uploaded here I got a red X and alt text, so maybe that's why x10 won't link a code I uploaded here?

    Here's a sample of the code, it's meant to retrieve the date and display an image that way:

    <?PHP
    date_default_timezone_set('UTC');
    switch(date('m-d')) {
    case '01-01':
    case '01-02':
    case '01-03':
    case '01-04':
    print '<img src="https://starka.x10hosting.com:2083/viewer/home%2fploinky/Lossless-circle-canny.png" alt="You should be seeing a white circle on a black background" />';
    break;
    // fallback image
    default:
    print '<img src="http://humanflowerproject.com/images/uploads/poi-gold-flower.jpg" alt="Image from a different site in case the other link is broken or messed up" />';
    break;
    }
    ?>

    (https://starka.x10hosting.com:2083/v.../thasampel.php Also, the syntax parts don't highlight..)

    LONG code if I want an image everyday, I know, but it's the only one I've found that does what I want and I'm new to PHP. BTW thanks for reading, guys.
    Last edited by koonoe49; 01-02-2011 at 04:45 PM.

  6. #6
    masshuu's Avatar
    masshuu is offline Head of the Geese masshuu has a spectacular aura about
    Join Date
    Oct 2007
    Location
    Las Colinas, Tx
    Posts
    2,262

    Re: Why doesn't my PHP code work?

    might i point out you should not be using https://starka.x10hosting.com:2083/viewer/
    this would "only" work if the person was logged into cpanel with your username at the time
    Just leading the flock.
    Livewire
    Masshuu ------ carl6969
    descalzo ------------------- Smith6612
    Bryon--------------------------------- Corey
    If you find any post helpful or useful, duck
    \ / This for that post and rep it up.

  7. #7
    koonoe49 is offline x10Hosting Member koonoe49 is an unknown quantity at this point
    Join Date
    Dec 2010
    Posts
    8

    Re: Why doesn't my PHP code work?

    I figured that, but I can't seem to find the raw URLs through file manager or right or left click..
    Last edited by koonoe49; 01-02-2011 at 04:50 PM.

  8. #8
    masshuu's Avatar
    masshuu is offline Head of the Geese masshuu has a spectacular aura about
    Join Date
    Oct 2007
    Location
    Las Colinas, Tx
    Posts
    2,262

    Re: Why doesn't my PHP code work?

    looking at it, thasampel.php and Lossless-circle-canny.png look like their in your root directory.
    If you move them to public_html, you can use

    year-of-the-sun.elementfx.com/thasampel.php
    year-of-the-sun.elementfx.com/Lossless-circle-canny.png
    Just leading the flock.
    Livewire
    Masshuu ------ carl6969
    descalzo ------------------- Smith6612
    Bryon--------------------------------- Corey
    If you find any post helpful or useful, duck
    \ / This for that post and rep it up.

  9. #9
    Anna's Avatar
    Anna is offline I am just me Anna is a name known to allAnna is a name known to all
    Join Date
    Aug 2007
    Location
    Sweden
    Posts
    6,569

    Re: Why doesn't my PHP code work?

    Image urls should always start with your main domain, or use a path relative to the document they are included in.

    Also you should note that if you want to be able to view the file in the browser, you need to place it inside the directory public_html, same goes for the images.

    Given the structure you currently have at /home/ploinky, the correct image url would be like
    Code:
    <img src="http://year-of-the-sun.elementfx.com/Lossless-circle-canny.png" />
    if you move all files into the folder public_html
    Do you have trouble reaching your site?
    Check here first: News and Announcements


    Don't forget that x10hosting has an irc server as well. Come and join the fun
    server: irc.x10hosting.com, main channel: #x10hosting
    There's a lot helpful users there if need help building your site

  10. #10
    koonoe49 is offline x10Hosting Member koonoe49 is an unknown quantity at this point
    Join Date
    Dec 2010
    Posts
    8

    Re: Why doesn't my PHP code work?

    Ok, thasampel works now that I've moved it like you said, but it still won't link in the html editor or code paster when I use
    <script type="text/javascript" src="myscript.php"></script> or <script type="php" src="myscript.php"></script> (though it doesn't seem to work in phpDesigner either..)

    BTW yes I'm testing with thasampel.
    Last edited by koonoe49; 01-02-2011 at 05:32 PM.

Closed Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. My confirmation code doesn't work !
    By be7ieve in forum Free Hosting
    Replies: 3
    Last Post: 02-19-2010, 07:08 PM
  2. Why doesnt this code work? ( PHP )
    By liguehs in forum Programming Help
    Replies: 6
    Last Post: 10-13-2009, 01:18 AM
  3. My code doesn't work as it should
    By slitharein in forum Graphics & Webdesign
    Replies: 2
    Last Post: 06-06-2009, 11:18 AM
  4. How to make the personal add code work?
    By Zlaxer in forum Free Hosting
    Replies: 1
    Last Post: 07-18-2008, 02:41 PM
  5. This code doesn't seem to work...
    By lambada in forum Scripts & 3rd Party Apps
    Replies: 8
    Last Post: 06-04-2006, 06:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers