We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Adding PHP to HTML issue

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>
3
Contributors
10
Replies
1 Day
Discussion Span
4 Months Ago
Last Updated
14
Views
Question
Answered
mpc123
Junior Poster
122 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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.

urtrivedi
Posting Virtuoso
1,724 posts since Dec 2008
Reputation Points: 299
Solved Threads: 366
Skill Endorsements: 24

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
mpc123
Junior Poster
122 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

just need whole code otherwsie cant find error

urtrivedi
Posting Virtuoso
1,724 posts since Dec 2008
Reputation Points: 299
Solved Threads: 366
Skill Endorsements: 24

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>
mpc123
Junior Poster
122 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

i dont find error in ur code, its compiles well

urtrivedi
Posting Virtuoso
1,724 posts since Dec 2008
Reputation Points: 299
Solved Threads: 366
Skill Endorsements: 24

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
mpc123
Junior Poster
122 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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']; ?>";

urtrivedi
Posting Virtuoso
1,724 posts since Dec 2008
Reputation Points: 299
Solved Threads: 366
Skill Endorsements: 24

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

mpc123
Junior Poster
122 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 4 Months Ago by urtrivedi

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

simplypixie
Practically a Master Poster
642 posts since Oct 2010
Reputation Points: 157
Solved Threads: 118
Skill Endorsements: 5

prefect thanks

mpc123
Junior Poster
122 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page generated in 0.0926 seconds using 2.71MB