Insert problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



G'day all,

I have a problem with an insert which is proving infuriating.  When I run
the following code everything seems to work (no errors) except the database
remains empty. When I echo $query and run it from a command line it inserts
fine.  I don't get any connection errors - in fact when I echo the
connection variables, it reflects a valid db connection.

Finally, if I change if (! $result = 1) to if (! $result = 0) it fires which
tends to indicate the query was successful.

Any suggestions would be most appreciated.

cheers

kim

$fileinfo = fopen($filepath, "r") OR die ("Failed to open the files
successfully");
$line = fgets($fileinfo, 1024);
$ad_num = substr($line,0, 19);
$page = substr($line,21, 4);
$section = substr($line,26, 6);
$width = substr($line,35, 5);
$height = substr($line,41, 7);
$client = substr($line,72, 20);
$xcoord = substr($line,135, 7);
$ycoord = substr($line,143, 7);
$publication = "Torch";
fclose($fileinfo); 

$db_name = "test";
$table_name = "dummy";
$connection = @mysql_connect("localhost","root","password") or die("Couldn't
Connect.");
$db = @mysql_select_db($db_name, $connection) or die("Couldn't select dummy
database.");

$query ="insert into dummy
(ad_num,width,height,client,page_number,publication,section,xpos,ypos)
VALUES 
('$ad_num','$width','$height','$client','$page','$publication','$section','$
xcoord','$ycoord')";

echo "$db_name"."<br>". "$table_name"."<br>". "$connection"."<br>"."$query";

if (! $result = 1)
{
echo "insert failed";
}


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux