Insert problem

From: Date: Mon, 11 Aug 2003 06:13:01 +0000
Subject: Insert problem
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-29810@lists.php.net to get a copy of this message
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"; }

« previous php.db (#29810) next »