#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Indonesia
    Posts
    87
    Rep Power
    15
    Hello there !!!

    I need some help here !!
    Okay, here's the problem :
    I have a form say it form.html, that will be proceed in engine.php3

    Before this form is proceed, i validate the form using JavaScript.

    In this JavaScript I need to take some variables from database (MySQL) ...
    So here's the problem.
    I put some PHP syntax to connect to database in JavaScript function, but it doesn't work.

    Not only the PHP syntax, but all of the syntax located in the JavaScript function do not work !!!

    WHY ????????
    Please anyone tell me how to do it.

    Example :

    <head>
    <script>

    function validateform(form)
    {
    <?
    $id = mysql_connect ("localhost","user","passwd");
    bla bla bla bla

    here i pull some variable from the database then validate the value
    ?>

    if (form.<? echo $var ?>.value = bla bla

    alert ("bla bla");
    }

    </script>
    </head>


    that's it !!!
    And it doesn't work !!
    Please please help me!!!


    ------------------
    ** It's the world of Oscario **
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    51
    Rep Power
    15
    check out www.phpbuilder.com. there is a pretty good article regarding this.

    /wj
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    2
    Rep Power
    0
    Have you tried rewriting the scripts so that the php-script that fetches the variables also prints out the javascript?
    Eg:
    <head>
    <?
    // Connect to database and fetch variables.
    // Print the javascript:
    echo "<script>";
    echo "function validateform(form) {";
    echo "if ($x == ".$var_from_db.") {";
    // and so on...
    echo "</script>";
    ?>
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Indonesia
    Posts
    87
    Rep Power
    15
    Schyman,

    thank's alot for the information !!

    It works ....

    See ya


    ------------------
    ** It's the world of Oscario **

Similar Threads

  1. Check MySQL Version thru PHP
    By wolftrap1 in forum PHP Development
    Replies: 2
    Last Post: February 11th, 2004, 08:51 PM
  2. Replies: 5
    Last Post: February 11th, 2004, 02:18 AM
  3. Replies: 0
    Last Post: February 10th, 2004, 11:44 PM
  4. Replies: 0
    Last Post: January 30th, 2004, 01:22 PM
  5. PHP 5 (MYSQL vs. SQLite)
    By ignition in forum PHP Development
    Replies: 1
    Last Post: January 23rd, 2004, 12:13 PM

IMN logo majestic logo threadwatch logo seochat tools logo