Re: doubt regarding mysql & php

From: Date: Sat, 28 Jul 2001 09:44:10 +0000
Subject: Re: doubt regarding mysql & php
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-60035@lists.php.net to get a copy of this message
Line 29: $sql2="UPDATE inventory SET inv_status="assigned" where inv_tag='$inv_tag' "; will give a php error - it should read either $sql2="UPDATE inventory SET inv_status='assigned' where inv_tag='$inv_tag' "; or $sql2="UPDATE inventory SET inv_status=\"assigned\" where inv_tag='$inv_tag' "; to be syntactically correct in php. Balaji Ankem schrieb am Samstag, 28. Juli 2001, 10:41:21: > Hi dearest friend, > can we update the same row immediately after selection. > please see the following code at line number 29 it is giving error. > code > ------------------------------------ > <?php > // Connect to MySQL > $connection = mysql_connect( 'localhost', 'balaji', > 'pingpong' ) > or die ( 'Unable to connect to server.' ); > // Select database on MySQL server > mysql_select_db( 'imac' ) > or die ( 'Unable to select database.' ); > // Formulate the query (inv_tag will come by post method > $sql1 = "SELECT * FROM inventory WHERE inv_tag = '$inv_tag'"; > // Execute the query and put results in $result > $result1 = mysql_query( $sql1 ) > or die ( 'Unable to select the data from inventory.' ); > if ( $result1 ) > { > //change the status of the inventory item in inventory table > $sql2="UPDATE inventory SET inv_status="assigned" where > inv_tag='$inv_tag' "; // This is line number 29. > $result2 = mysql_query( $sql2 ) > or die ( 'Unable to execute query for upadation of inventory > table.' ); > $sql3 = "insert into status > values('$inv_name','$inv_type','$inv_tag','$issued_to','$issued_by','$issue_date')"; > $result3 = mysql_query( $sql3 ) > or die ( 'Unable to execute query for insertion in to status > table.' ); > } > else > { > // header( 'WWW-Authenticate: Basic realm="Private"' ); > // header( 'HTTP/1.0 401 Unauthorized' ); > echo '$inv_tag does not exist'; > exit; > } > ?> > please inform if any errors. > Thanks in advance. > Regards > -Balaji -- Herzlich Werner Stuerenburg _________________________________________________ ISIS Verlag, Teut 3, D-32683 Barntrup-Alverdissen Tel 0(049) 5224-997 407 · Fax 0(049) 5224-997 409 http://pferdezeitung.de

« previous php.general (#60035) next »