Jump to content

[SOLVED] Insert fails occasionally


Studio381

Recommended Posts

Hi,

  I'm new to all this but have a site that has been up and running for a number of months.

I have an insert query that fails now and again.

What puzzles me is why it fails occasionally and not every time. The code for the insert is straightforward...

 

include("misc.inc");

 

  $connection = mysql_connect($host,$user,$password)

      or die ("couldn't connect to server");

  $db = mysql_select_db($database,$connection)

      or die ("Couldn't select database");

 

 

 

$query = "INSERT INTO BasicTable

(Fname,

Sname,

City,

County,

State,

FirstwillID)

VALUES

('$fname',

'$sname',

'$city',

'$county',

'$state',

'$willidfirstperson')"; 

 

 

  $result = mysql_query($query)

      or die ("Couldn't execute query1222basic1_601.");

 

(I removed some of the entries in the Input query for the sake of space). This is the only piece of code that inserts a new record.

 

 

Now if there was an error in the format of the insert statement it would fail every time, right? So I thought that maybe the values of what I was trying to insert might be causing the problem. However if I create a new record and enter these values into the database manually it all works.

So what else should I look for that could be causing the problem?

Thanks,

John.

 

Link to comment
https://forums.phpfreaks.com/topic/111632-solved-insert-fails-occasionally/
Share on other sites

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.