jquery with php loading file

Posted by Marcus Solv on Stack Overflow See other posts from Stack Overflow or by Marcus Solv
Published on 2012-04-13T23:19:36Z Indexed on 2012/04/13 23:29 UTC
Read the original article Hit count: 194

Filed under:
|

I'm trying to use jquery with a simple php code:

$('#some').click(function() {
    <?php
    require_once('some1.php?name="some' + index + '"');
    ?>
});

It shows no error, so I don't know what is wrong.

In some1 I have:

<?php
    //Start session
    session_start();

    //Include database connection details
    require_once('../sql/config.php');

    //Connect to mysql server
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
    if(!$link) {
        die('Failed to connect to server: ' . mysql_error());
    }

    //Select database
    $db = mysql_select_db(DB_DATABASE);
    if(!$db) {
        die("Unable to select database");
    }

    //Function to sanitize values received from the form. Prevents SQL injection
    function clean($str) {
        $str = @trim($str);
        if(get_magic_quotes_gpc()) {
            $str = stripslashes($str);
        }
        return mysql_real_escape_string($str);
    }

    //Sanitize the POST values
    $name = clean($_GET['name']);
?>

It's not complete because I want to make a sql command (insert).

I want when I click in #some to execute that file (create a entry in the table that isn't define yet).

© Stack Overflow or respective owner

Related posts about php

Related posts about jQuery