alin19 Posted January 18, 2008 Share Posted January 18, 2008 it was a comand that i can't find, with afected rows $query="UPDATE test SET tra='$arr[0]', simbol='$arr[1]' WHERE tra='test'"; if //afected row= 0 then $query= "INSERT INTO `test` ( `id` , `tra` , `simbol` ) VALUES ( '', '$arr[0]', '$arr[2]')"; Link to comment https://forums.phpfreaks.com/topic/86618-solved-update-in-mysql/ Share on other sites More sharing options...
pdkv2 Posted January 18, 2008 Share Posted January 18, 2008 int mysql_affected_rows ( [resource $link_identifier] ) Link to comment https://forums.phpfreaks.com/topic/86618-solved-update-in-mysql/#findComment-442619 Share on other sites More sharing options...
alin19 Posted January 18, 2008 Author Share Posted January 18, 2008 $query="UPDATE test SET tra='$arr[0]', simbol='$arr[2]', piata='$arr[1]', bidvol='$arr[3]', bestbid='$arr[4]' , bestask='$arr[5]' , bidask='$arr[6]' , pret='$arr[8]' , volum='$arr[7]' , nrtra='$arr[9]' , data='$arr[10]' , var='$arr[11]' WHERE simbol='$arr[2]'"; if (mysql_query($query)) { echo 'good'; } else { echo 'bad'; } --------if (int mysql_affected_rows ( (resource $link_identifier) )=0) { $query= "INSERT INTO `test` ( `id` , `tra` , `simbol` , `piata` , `bidvol` , `bestbid` , `bestask` , `bidask` , `pret` , `volum` , `nrtra` , `data` , `var` ) VALUES ( '', '$arr[0]', '$arr[2]', '$arr[1]', '$arr[3]', '$arr[4]', '$arr[5]', '$arr[6]', '$arr[8]', '$arr[7]', '$arr[9]' , '$arr[10]', '$arr[11]' )"; } i'm still geting an error at that line: PHP Parse error: syntax error, unexpected T_VARIABLE on line 42 Link to comment https://forums.phpfreaks.com/topic/86618-solved-update-in-mysql/#findComment-442625 Share on other sites More sharing options...
rajivgonsalves Posted January 18, 2008 Share Posted January 18, 2008 this if (int mysql_affected_rows ( (resource $link_identifier) )=0) should be if (mysql_affected_rows()==0) Link to comment https://forums.phpfreaks.com/topic/86618-solved-update-in-mysql/#findComment-442629 Share on other sites More sharing options...
pdkv2 Posted January 18, 2008 Share Posted January 18, 2008 Yes this should work Link to comment https://forums.phpfreaks.com/topic/86618-solved-update-in-mysql/#findComment-442639 Share on other sites More sharing options...
alin19 Posted January 18, 2008 Author Share Posted January 18, 2008 10x Link to comment https://forums.phpfreaks.com/topic/86618-solved-update-in-mysql/#findComment-442654 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.