Jump to content

[SOLVED] Cannot INSERT data


ShaolinF

Recommended Posts

Hi Guys

 

I am trying to insert some data into the database but its not working. The db connects and everything and I receive no errors. See code below:

 

$id = $_POST['id'];

$name = $_POST['name'];

 

//Connect to DB

connect();

$insert = mysql_query("INSERT INTO petition values('','".$id."','".$name.")");

 

function connect() {

$link = mysql_connect('localhost', 'petitUsr', '12345678a');

if (!$link) {

die('Could not connect to database: ' . mysql_error());

}

$selected = mysql_select_db('petition',$link) or die(mysql_error());

}

 

 

Anyone know what Im doing wrong?

 

Link to comment
Share on other sites

add or die

 

Lol... Read it aloud and listen how it sounds. Better yet shout it out: ADD OR DIE!!! :D

 

Heh... anyway...

What Blade meant was

add

or die(mysql_error()); 

after your query

 

$insert = mysql_query("INSERT INTO petition values('','".$id."','".$name.")") or die(mysql_error());

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.