SEO Software
Closed Thread
Results 1 to 3 of 3

Thread: Error in php script, need help

  1. #1

    Default Error in php script, need help

    When ever I load a certain page on my website, I get this message:

    http://conmiro.com/submit.php

    Here is the script of submit.php:

    <?php
    $con = mysql_connect("localhost","conmiro_conmiro","godje sus");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }mysql_select_db("my_db", $con);mysql_query
    ("INSERT INTO websites (sitename, description, email)
    VALUES ('$_POST["age"]', '$_POST["age"]', '$_POST["age"]')");
    mysql_close($con);
    ?>


    If you can help me, il give you some points.


  2. SEO Software

  3. #2
    Retired Spyros has a spectacular aura about Spyros has a spectacular aura about
    Join Date
    May 2006
    Location
    Athens, Hellas
    Posts
    1,249
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hello Conmiro, can you try this code;

    PHP Code:
    <?php

        $con 
    mysql_connect('localhost''conmiro_conmiro''godjesus');
        
        if(!
    $con) {
            die(
    'Could not connect: '.mysql_error());
        } else {
            
    mysql_select_db('my_db'$con);
            
            
    mysql_query('INSERT INTO `websites` (`sitename`, `description`, `email`) VALUES (`'.$_POST['age'].'`, `'.$_POST['age'].'`, `'.$_POST['age'].'`');
            
    mysql_close($con);
        }

    ?>
    instead and give me its output?

    I changed your query a bit, since strings enclosed within the single quote (') cannot identify/parse variables.

  4. #3
    Fulltime Member Arbitrary will become famous soon enough
    Join Date
    Jul 2006
    Location
    Adblock life
    Posts
    514
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    <?php
    $con = mysql_connect("localhost","conmiro_conmiro","godje sus");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }mysql_select_db("my_db", $con);mysql_query
    ("INSERT INTO websites (sitename, description, email)
    VALUES ('$_POST["age"]', '$_POST["age"]', '$_POST["age"]')");
    mysql_close($con);
    ?>
    It won't work because you won't be able to parse if there are double quotes within double quotes. You can either have single quotes within double or double in single, but if you have double within double, php won't know where the delimiter for the quotes are. Sypros's method should get things working.

Closed Thread

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