ThunderAI Posted August 20, 2008 Share Posted August 20, 2008 I admit this isn't really just a PHP problem, but it does have PHP elements to it. Here is my problem. I have an SQL statement that works and will submit data to the MYSQL table, BUT MySQL gives an error message. Any ideas? Here is the error statement: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'files/1/KATY.csv', user_f_rows = '42' WHERE user_f_id = '1' ] ')' at line 1 the sql statement print out is: SQL is [[[ UPDATE tbl_users_files SET user_f_name = 'files/1/KATY.csv', user_f_rows = '42' WHERE user_f_id = '1' ]]] This error happens reguardless if i am overwiting an exisiting file or not. It does add the new record to the DB with all of the right information. here is the code: <? else { $objrs_support = mysqli_query($objconn_support, $sql); if ($objrs_support) { $number_of_rows = mysqli_num_rows($objrs_support); if ($number_of_rows == 0) { // There are no records, so this is a new entry $sql2 = "INSERT INTO tbl_users_files (user_f_name,user_f_rows, user_f_parent_id) VALUES ( '".$target_path."', '".$rowcounter."', '".$tmp_userid."' )"; } while ($objfields = mysqli_fetch_array($objrs_support, MYSQLI_ASSOC)) { $tmp_user_f_id = $objfields['user_f_id']; $sql2 = "UPDATE tbl_users_files SET user_f_name = '".$target_path."', user_f_rows = '".$rowcounter."' WHERE user_f_id = '".$tmp_user_f_id."' "; echo "SQL is [[[ ".$sql2." ]]]"; } } } //echo $sql2; $mysqli = mysqli_connect("-", "-", "-", "-"); if (mysqli_connect_errno()) { // there was an error trying to connect to the mysql database printf("connect failed: %s\n", mysqli_connect_error()); exit(); } else { $objrs = mysqli_query($mysqli, $sql2) or die(mysqli_error($mysqli)); //printf("Last inserted record has id %d\n", LAST_INSERT_ID()); //echo mysql_insert_id($mysqli); } $function = "Uploaded a new User CSV file with SQL Statement [ ".$sql2." ] "; put_systemactivity($_SESSION["user_id"],$function); ?> Please pardone the code, im not a great programmer, just a programmer. Quote Link to comment https://forums.phpfreaks.com/topic/120597-php-sql-error-and-i-dont-get-it/ Share on other sites More sharing options...
akitchin Posted August 20, 2008 Share Posted August 20, 2008 strange. does the query work if you run it from console or PMA or whatever administration tool you have installed? also, does it work if you drop the user_f_name from that (ie. just update the user_f_rows)? Quote Link to comment https://forums.phpfreaks.com/topic/120597-php-sql-error-and-i-dont-get-it/#findComment-621425 Share on other sites More sharing options...
ThunderAI Posted August 21, 2008 Author Share Posted August 21, 2008 strange. does the query work if you run it from console or PMA or whatever administration tool you have installed? also, does it work if you drop the user_f_name from that (ie. just update the user_f_rows)? The SQL works without error when entereted into PHPMyAdmin. If the user uploads a file with a different name i need to save the name of the file, so I dont see how removing the name will benefit me. Tried it again this morning and I get the same error. Quote Link to comment https://forums.phpfreaks.com/topic/120597-php-sql-error-and-i-dont-get-it/#findComment-621952 Share on other sites More sharing options...
akitchin Posted August 21, 2008 Share Posted August 21, 2008 i was suggesting that not as a final solution, but just to check whether it's that specific parameter that's causing the error. as far as i can tell, there's no error - could just be a mysqli extension issue; how does it do if you switch to regular mysql_query()? (obviously you'll need to change the connection functions). Quote Link to comment https://forums.phpfreaks.com/topic/120597-php-sql-error-and-i-dont-get-it/#findComment-622138 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.