Results 1 to 3 of 3

Thread: PHP in HTML But the href links dont work

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2009
    Posts
    113

    PHP in HTML But the href links dont work

    I have a php script that has HTML in it.

    I start by creating the top header section with menu buttons. Now the buttons work and you can click them.

    Then there is a php code section where I connect to a MYSQL database and then use echo statements to output some HTML code. THen i close the PHP section add some HTML code the close the BODY and HTML.

    Problem is ALL links created using the echo statements are "dead" they ARE displayed as links but you cant click them. Why is this?

    Is seems like all the links before the php code work and all those in and after the php code statement dont...

    Heres the code (shortened)

    Code:
    <HTML><HEAD>
    <TITLE>test</TITLE>
    <style type="text/css"> .divScrollAuto {overflow:auto;    white-space:nowrap;}</style>
    <script type="text/javascript">
    function changeWidth(iid,img,divh)
    {
    var elem = document.getElementById(iid);
    var newImg = new Image();
    newImg.src = img;
    var height = newImg.height;
    var width = newImg.width;
    elem.width=(divh/height)*width; 
    elem.height=divh;
    }
    </script>
    
    </HEAD><BODY style="width: 1000px;height: 1000px;background-color: #FFFFFF; background-image: url(images/background1.png);background-repeat:no-repeat;">
    
    <?php
    	//get our vars
    	$location = $_POST['searchLocation'];
            //etc...etc....
    
    //connect to mysql database
    //get values
    
    while ($row = mysql_fetch_assoc($result)) 
     {
     echo "<a href=\"/test/".strval($row["id"]).".php\" target=\"_blank\">".$row["test2"]."</a>    -    £".$row["test4"]."<br />";
     }
     
    echo "</DIV><br /><br /><br /><br />Copyright © 2012, UK";
    
    mysql_free_result($result);
    mysql_close($dbc);
    ?>
    <a href='http://www.mysite.co.uk' target='_blank'>GO BACK</a><br />//this link doesnt work either
    
    </BODY></HTML>

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: PHP in HTML But the href links dont work

    This works, (using my website url as an example):

    HTML Code:
    <a href="http://aaronspehr.net" target='_blank'>GO BACK</a><br />
    The website either doesn't exist or the index page has nothing on it.

    This is what appears when I run your code.

    Notice: Undefined index: searchLocation in C:\wamp\www\New folder\new1.php on line 21

    Notice: Undefined variable: result in C:\wamp\www\New folder\new1.php on line 27

    Warning: mysql_fetch_assoc() expects parameter 1 to be resource, null given in C:\wamp\www\New folder\new1.php on line 27

    Copyright © 2012, UK
    Notice: Undefined variable: result in C:\wamp\www\New folder\new1.php on line 34

    Warning: mysql_free_result() expects parameter 1 to be resource, null given in C:\wamp\www\New folder\new1.php on line 34

    Notice: Undefined variable: dbc in C:\wamp\www\New folder\new1.php on line 35

    Warning: mysql_close() expects parameter 1 to be resource, null given in C:\wamp\www\New folder\new1.php on line 35
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2009
    Posts
    113

    Re: PHP in HTML But the href links dont work

    its working now .

    the problem is this. when i centred the echoed html it dint work. when i removed the line
    echo "<CENTER>" The it worked

    i dont see why but thats what was causing it.

    Is it cos i didnt have echo "</CENTER>" at the end

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width