Jump to content

[SOLVED] Problem Inserting Data into SQL Table


Akenatehm

Recommended Posts

Hey Guys,

 

I am trying to insert data into a MySQL table, it is showing one of the if error messages ("Could not insert comment")

 

Any help would be greatly appreciated.

 

Here is my code:

 

<?php

include "connect.php";

if(isset($_POST['submit']))

{

   $username=$_POST['username'];

   $password=$_POST['password'];
   
   $email=$_POST['email'];

   if(strlen($username)<1)

   {

      print "You did not enter a username.";

   }

   else if(strlen($password)<1)

   {

      print "You did not enter a password.";

   }

   else

   {

      $insert="Insert into users (username,password,email) values('$username','$password','$email')";

      mysql_query($insert) or die("Could not insert comment");
  
  print "Comment added. <A href='display.php'>Click here</a> to see all comments.";
   }

  }

?>

As far as I know it is connecting because it wasn't before and now it's not showing those errors. Anyway here it is:

 

<?PHP

$db = mysql_connect ("localhost", "username", "password");

if (!$db)

	die ("No Database Found");

if (!mysql_select_db ("kaurlcom_messenger",$db))

	die("No Database Selected");

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.