Results 1 to 6 of 6

Thread: sql not functioning on submit

  1. #1
    Join Date
    Jun 2006
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Talking sql not functioning on submit

    hey all the php is correct but now i need a guru to test the sql or please advise as how to fix it. i dont belive it is working correctly becasue i am not getting any data into my database. i hope this isnt double posting i belive it is two diferent questions. thankx for your help sql pros
    PHP Code:
    <?php
    /////////////////////Connect to Database///////////////
    $link mysql_connect('localhost''session''123456');
    if (!
    $link) {
       die(
    'Could not connect: ' mysql_error());
    }
    //echo 'Connected successfully';

    ?> 
    <?php
    session_start
    ();
    ?>
    <?php
    /////////////////////////Submission Counter///////////////////////
    function submissionCounter(){

    $submissionCounter "SELECT * FROM submissionCounter";
    $check mysql_query($submissionCounter);

    if(!
    session_is_registered('submitted')){
        
    $check("INSERT INTO submissionCounter (session_id, ip_address, user_agent) VALUES ('".session_id()."', WHERE ip_address='{$_POST['REMOTE_ADDR']}', AND user_agent='{$_POST['HTTP_USER_AGENT']}')");
        
    mysql_query($check);
        
    session_register('submitted');
    } else {
        if(
    session_is_registered('user_id')){
            
    $check("UPDATE submissionCounter, total_visit SET member='1' WHERE session_id='".session_id()."'");
             
    mysql_query($check);

        }
    }
    if(
    session_is_registered('submitted')){        
        
    $check("UPDATE submissionCounter WHERE session_id='".session_id()."'");
            
    mysql_query($check);


    if(
    session_is_registered('complete')){
        
    $check("SELECT function(SUM(total_visit)) FROM submissionCounter");
            
    mysql_query($check);

    }
    //echo 'function works';
    }
    ?>
    <?php
    //this would go on the submit form
    if (isset($_POST["Submit"]))
    {
        
    submissionCounter();
        
    $xamount "1";
        for (
    $i 0$i $xamount$i++)
        {
            if (!empty(
    $xamount[$i]))
            {
                echo 
    "contest is over";
            }
        }
    }
    ?> 
    <html>
    <head></head>
    <body>
    <form action="" method="post">
      <input name="test" type="text" maxlength="5" value="" size="5" >
      <input name="test2" type="text" maxlength="3" value="" size="4" >
      <input type="submit" value="Submit" >
    </form>
    </body>
    </html>
    <!--sqlsqlsqlsqlsqlsqlsqlsqlsqlsqlsqlsqlsql--
    CREATE TABLE submissionCounter (
      session_id varchar(255) NOT NULL default '',
      total_visit varchar(150) NOT NULL default '0',
      member enum('1','0') default '0',
      ip_address varchar(255) NOT NULL default '',
      user_agent varchar(255) default NULL,
      PRIMARY KEY  (session_id),
      KEY session_id (session_id)
    ) TYPE=MyISAM;
    -------------------------------------------->
    <?php
    mysql_close
    ($link);
    ?>
    Last edited by pkcidstudio; 08-02-2006 at 05:06 PM.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    What the heck? Is that a <br> tag in the middle of your SQL?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jun 2006
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Talking

    my bad, my hand slipped i have since taken it out. any other thoughts on how to get this up and running before i leave town for a few days. thankx all fro the help.

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Well, add:
    Code:
     or die(mysql_error());
    after your mysql_query() calls (remove the existing semicolons) and give us the output.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Jun 2006
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    if i am doing this right i am getting blank screens
    PHP Code:
    <?php
    /////////////////////Connect to Database///////////////
    $link mysql_connect('localhost''session''123456');
    if (!
    $link) {
       die(
    'Could not connect: ' mysql_error());
    }
    //echo 'Connected successfully';

    ?> 
    <?php
    session_start
    ();
    ?>
    <?php
    /////////////////////////Submission Counter///////////////////////
    function submissionCounter(){

    $submissionCounter "SELECT * FROM submissionCounter";
    $check mysql_query($submissionCounter);

    if(!
    session_is_registered('submitted')){
        
    $check("INSERT INTO submissionCounter (session_id, ip_address, user_agent) VALUES ('".session_id()."', WHERE ip_address='{$_POST['REMOTE_ADDR']}', AND user_agent='{$_POST['HTTP_USER_AGENT']}')");
        
    mysql_query($check);
         or die(
    mysql_error());
        
    session_register('submitted');
    } else {
        if(
    session_is_registered('user_id')){
            
    $check("UPDATE submissionCounter, total_visit SET member='1' WHERE session_id='".session_id()."'");
             
    mysql_query($check);
              or die(
    mysql_error());

        }
    }
    if(
    session_is_registered('submitted')){        
        
    $check("UPDATE submissionCounter WHERE session_id='".session_id()."'");
            
    mysql_query($check);
             or die(
    mysql_error());


    if(
    session_is_registered('complete')){
        
    $check("SELECT function(SUM(total_visit)) FROM submissionCounter");
            
    mysql_query($check);
             or die(
    mysql_error());

    }

    //echo 'function works';
    }
    ?>
    <?php
    //this would go on the submit form
    if (isset($_POST["Submit"]))
    {
        
    submissionCounter();
        
    $xamount "1";
        for (
    $i 0$i $xamount$i++)
        {
            if (!empty(
    $xamount[$i]))
            {
                echo 
    "contest is over";
            }
        }
    }
    ?> 
    <html>
    <head></head>
    <body>
    <form action="" method="post">
      <input name="test" type="text" maxlength="5" value="" size="5" >
      <input name="test2" type="text" maxlength="3" value="" size="4" >
      <input type="submit" value="Submit" >
    </form>
    </body>
    </html>
    <!--sqlsqlsqlsqlsqlsqlsqlsqlsqlsqlsqlsqlsql--
    CREATE TABLE submissionCounter (
      session_id varchar(255) NOT NULL default '',
      total_visit varchar(150) NOT NULL default '0',
      member enum('1','0') default '0',
      ip_address varchar(255) NOT NULL default '',
      user_agent varchar(255) default NULL,
      PRIMARY KEY  (session_id),
      KEY session_id (session_id)
    ) TYPE=MyISAM;
    -------------------------------------------->
    <?php
    mysql_close
    ($link);
    ?>
    Last edited by pkcidstudio; 08-02-2006 at 05:10 PM.

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Quote Originally Posted by myself
    (remove the existing semicolons)
    Code:
        mysql_query($check);
         or die(mysql_error());
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •