Web Analytics Made Easy -
StatCounter Dynamic PHP - CodingForum

Announcement

Collapse
No announcement yet.

Dynamic PHP

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dynamic PHP

    I want to make a dynamic PHP page.
    My idea is store javascript in myql (in a text field) and load data into variable $dynamic when it want to use (only need to echo $dynamic).
    And the same idea to create static page with mysql (HTML only). All tag will store in mysql and when I need them, just to load it out.
    But both of my idea have problem with parsing error.
    Can anyone help me

    Thank

  • #2
    You should post your code we see what you're doing!

    Comment


    • #3
      Just select the data from the MySQL table when you need it.

      Comment


      • #4
        I don't have my code at my home now. This my idea :
        I have a database name dynamic. It has a table named static.
        Static table has two fields : id (primary) ==> number of template; content (text) ==> all HTML tag neccessary.
        Connect to MySQL :

        $result=mysql_query("SELECT * FROM static";
        if(!$result) fail("database query failed, login page", true);
        // fail is my function
        if(mysql_num_rows($result)>0){
        $record=mysql_fetch_assoc($result);
        $id=$record["id"];
        $content=$record["logged_in_user"];
        }

        Diplay in PHP :

        echo $content;

        Comment


        • #5
          Your idea is perfectly fine and it's something that we (PHP scripters) use all the time (partially in my case!). The semantics are fine, it should be something with the syntax and without seeing your code I can't tell ya what it is.

          Comment


          • #6
            In Mysql, I put in field static (style : TEXT)

            "<HTML>
            <HEAD>
            <TITLE>My template</TITLE>
            </HEAD>
            <STYLE>
            H1 {color:#CCCCCC; font:bold 16pt 'Verdana','Tahoma','Ariral'}
            H2 {color:#CCCCCC; font:bold 12pt 'Verdana','Tahoma','Ariral'}
            P {color:#CCCCCC; font:bold 10pt 'Verdana','Tahoma','Ariral'}
            A:link {color:#FF0000; font:bold 10pt}
            A:hover{color:#FFFF33;font:bold 10pt}
            A:visited{{color:#CC9900;font:bold 10pt}
            </STYLE>
            <BODY BGCOLOR='#000066' TEXT='#CCCCCC'>
            <H1 align='center'>$title</H1>
            <P>";

            Comment


            • #7
              I see nothing wrong with your code, but lemme show ya one simple technique that I'm sure you know yourself, but sometimes we forget it. Try to reduce your code as much as possible and test it, if it works, then add some other lines to it and test it again, continue this test until you encounter your first error, this time you know what lines are buggy and you should fix them!

              Comment


              • #8
                Welcome here!

                I see a lot of problems with both your HTML and your PHP code. Post back in you want info on them.

                If you just wan't to get rid of the errors, then post the errormessages you get + the actual code (the relevant parts) or follow ConfusedOfLifes advice.
                Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

                Comment


                • #9
                  I am trying to repair my code myself. I had split my code into smallest as possible. And the static is run well.
                  Here is the code :
                  <?
                  $db=mysql_pconnect("localhost");
                  mysql_select_db("dynamic",$db);

                  $result=mysql_query("SELECT * FROM static");
                  if(!$result) echo "fail";
                  if(mysql_num_rows($result)>0){
                  $record=mysql_fetch_assoc($result);
                  $id=$record["id"];
                  $content=$record["content"];
                  echo $content;
                  exit;
                  }
                  else{
                  echo "Please try again.<BR>";
                  }
                  ?>
                  I had rejected " and "; in HTML text that I post last time (it is small error)
                  Now I am trying to test with dynamic part, if I got error I will ask you. If you have any example, can you send me (I just need to catch the idea, and simple example may helpful to me)

                  Thanks

                  Comment

                  Working...
                  X