Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jun 2010
    Posts
    42
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Setup WAMPSERVER?

    Hi, I have just downloaded WAMPSERVER 2.0i and I don't think it's working properly, I have Windows 7 64bit and I don't know if thats causing the problem. I am making a script with jquery and php, the php script keeps coming up with an error in Firebug.

    I click the submit buttom on my form and in the Firebug box it shows all the php script and an error underneath saying

    "no element found

    ?> submit_to_db.php(line 18)"


    These are the main codes


    index.html
    Code:
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">
    </script>
    
    <script type="text/javascript">
    $(function() {
    	$('#submit').click(function() {
    		$('#container').append('<img src="loading.gif" alt="Currently Loading" id="loading" />');
    		
    		var name = $('#name').val();
    		var email = $('#email').val();
    		var comments = $('#comments').val();
    		
    		$.ajax({
    			url: 'submit_to_db.php',
    			type: 'POST',
    			data: 'name=' + name + '&email=' + email + '&comments=' + comments,
    			
    			success: function(result) {
    			
    			console.log(result);
    				
    			}
    			
    		});
    		
    		return false;
    		
    		});
    });
    </script>
    
    </head>
    <body>
    <form method="post" action="submit_to_db.php">
    <div id="container">
    <label for="name">Name:</label>
    <input type="text" name="name" id="name" />
    
    <label for="email">E-Mail:</label>
    <input type="text" name="email" id="email" />
    
    <label for="comments">Comments:</label>
    <textarea name="comments" id="comments" rows="5" cols="35"></textarea>
    <br/>
    <input type="submit" name="submit" id="submit" value="Go!" />
    </div>
    </form>
    submit_to_db.php
    Code:
    <?php
    
    $conn = new mysqli('localhost', 'root', '', 'my_db');
    $query = "INSERT into comments(name, email, comments) VALUES (?, ?, ?)";
    
    $stmt = $conn->stmt_init();
    if($stmt->prepare($query)) {
    	$stmt->bind_param('sss', $_POST['name'], $_POST['email'], $_POST['comments']);
    	$stmt->execute();
    }
    
    if($stmt) {
    echo "Thank you. We'll be in touch with you shortly!";
    } else {
    echo "There was a problem. Please  try again later.";
    }
    
    ?>
    Thanks

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Sounds like your Apache is not configured to execute .php file using PHP.
    Open your httpd.conf file (located in you're Apache/conf directory), and search for AddType. If you don't find one thats like so:
    Code:
    AddType application/x-httpd-php .php
    Go ahead and add that and restart your apache service.

    Try that and post back if its still a problem. The firebug error is because its trying to interpret the <?php ....?> as a tag, which of course doesn't exist.

    Edit:
    Otherwise, it looks ok, so I'm fairly certain this is an Apache configuration issue, so I'll move it to the appropriate forum.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    New Coder
    Join Date
    Jun 2010
    Posts
    42
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I searched for that bit of text and it was already there. What else could be the problem?

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    When you access the page, you are doing so from a web-browser and typing it as a url right? So its http:// and not file://?
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #5
    New Coder
    Join Date
    Jun 2010
    Posts
    42
    Thanks
    2
    Thanked 0 Times in 0 Posts
    it doesn't work when I type http:// infront of it, how do I make it work?

  • #6
    New Coder
    Join Date
    Jun 2010
    Posts
    42
    Thanks
    2
    Thanked 0 Times in 0 Posts
    doesnt matter i've got it. But im getting an error now saying

    Code:
    console is not defined
    console.log(result)                                                                    submit_to_db(line 26)

  • #7
    New Coder
    Join Date
    Jun 2010
    Posts
    42
    Thanks
    2
    Thanked 0 Times in 0 Posts
    haha no thats fine aswell, i didnt enter anything into the field!! thanks for the help.

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    So you got it all sorted out?
    If I had to guess it, you probably just didn't have either http://127.0.0.1 or http://localhost in the address. This is required when processing PHP through your localsystem apache (PHP is also runnable from the command line, but you couldn't add your JS directly to it).
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

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