1,105,333 Community Members

Adding PHP to HTML issue

Member Avatar
mpc123
Junior Poster
160 posts since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

HI , I basically have made something that I require work in html but now trying to convert to get the results from data base but get this error and cant work out how to change it, if someone could help

unexpected T_STRING, expecting ',' or ';' on line 69

***********all my css and database connection and query stuff**********************











while($row = mysql_fetch_array($result)){

            echo '<div class="BoxContainer">
    <div class="contentBox">
        <span class="inBoxTitle green">green box</span>



        <!-- Demo Button! -->
        <button class="botGreen" id="botSmallPic1">Picture 1</button>



    </div>






</div> <!-- .BoxContainer -->





<script src="/css/static/js/box.js"></script>


 <script type="text/javascript">



    $("#botSmallPic1").click(function(){
        $.smallBox( 
        {
            title: "",
            content: "",

            color: "#ec008c",
            img: "",
            icon: ""
        }
        );

    });


 </script>';
}

?>
</body>
</html>
Member Avatar
urtrivedi
Posting Virtuoso
1,900 posts since Dec 2008
Reputation Points: 249 [?]
Q&As Helped to Solve: 409 [?]
Skill Endorsements: 27 [?]
 
0
 

post complete code, $row is not used anywhere in your code,
so better you write php code where needed,
dont include all static html code in php echo.

Member Avatar
mpc123
Junior Poster
160 posts since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi

Thanks for the reply

Yeah im adding the $row info later as there is a lot of it, that why im trying to get rid of these issues first

It looks like the problem is with this area

{
            title: "",
            content: "",
            color: "#ec008c",
            img: "",
            icon: ""
        }
        );
    });



with the fetch result also wanting info between the } this means it obviously thinks it stops there, hoiw do i get round this please?

Thanks
Member Avatar
urtrivedi
Posting Virtuoso
1,900 posts since Dec 2008
Reputation Points: 249 [?]
Q&As Helped to Solve: 409 [?]
Skill Endorsements: 27 [?]
 
0
 

just need whole code otherwsie cant find error

Member Avatar
mpc123
Junior Poster
160 posts since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Sorry here you go

<body>
<?php
$con = mysql_connect("","","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("", $con);

$result = mysql_query("my query") or trigger_error(mysql_error().$sql);
while($row = mysql_fetch_array($result)){

            echo '<div class="BoxContainer">
    <div class="contentBox">
        <span class="inBoxTitle green">A box</span>



        <!-- Demo Button! -->
        <button class="botGreen" id="botSmallPic1">Picture 1</button>



    </div>






</div> <!-- .BoxContainer -->





<script src="/css/static/js/box.js"></script>


 <script type="text/javascript">


    // ======== Box
    $("#botSmallPic1").click(function(){
        $.smallBox( 
        {
            title: "",
            content: "",

            color: "#ec008c",
            img: "",
            icon: ""
        }
        );

    });


 </script>';
}

?>
</body>
</html>
Member Avatar
urtrivedi
Posting Virtuoso
1,900 posts since Dec 2008
Reputation Points: 249 [?]
Q&As Helped to Solve: 409 [?]
Skill Endorsements: 27 [?]
 
0
 

i dont find error in ur code, its compiles well

Member Avatar
mpc123
Junior Poster
160 posts since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

thanks for the reply but it says there is an error and I think there is around the

// ======== Box
    $("#botSmallPic1").click(function(){
        $.smallBox( 
        {
            title: "",
            content: "",
            color: "#ec008c",
            img: "",
            icon: ""
        }
        );
    });

    due to the { } which are in the code as the php result code says in between { }. I have no idea how to get round it
Member Avatar
urtrivedi
Posting Virtuoso
1,900 posts since Dec 2008
Reputation Points: 249 [?]
Q&As Helped to Solve: 409 [?]
Skill Endorsements: 27 [?]
 
0
 

are u sure u going to put some $row value in this javascript?, if not, then just keep this script out of php, becasue if u keep it in loop, the script will generate number of times the records are in ur query.

or use something like,
title="<?php echo $row['somevalue']; ?>";

Member Avatar
mpc123
Junior Poster
160 posts since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

yes im going to be putting the $row information in, im getting rid of this problem then i can go and add all that information

Question Answered as of 1 Year Ago by urtrivedi
Member Avatar
simplypixie
Practically a Master Poster
673 posts since Oct 2010
Reputation Points: 123 [?]
Q&As Helped to Solve: 122 [?]
Skill Endorsements: 6 [?]
 
0
 

Do what urtrivedi has advised and remove all your html and javascript from the php and see if your problem is resolved

while($row = mysql_fetch_array($result)){ ?>

    <div class="BoxContainer">
    <div class="contentBox">
        <span class="inBoxTitle green">A box</span>
        <!-- Demo Button! -->
        <button class="botGreen" id="botSmallPic1">Picture 1</button>
    </div>
</div> <!-- .BoxContainer -->

 <script type="text/javascript">

    // ======== Box
    $("#botSmallPic1").click(function(){
        $.smallBox( 
        {
            title: "",
            content: "",

            color: "#ec008c",
            img: "",
            icon: ""
        }
        );

    });

 </script>

<?php } ?>

And you won't need to call the external js file in your while loop so move <script src="/css/static/js/box.js"></script> to your head

Member Avatar
mpc123
Junior Poster
160 posts since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

prefect thanks

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article