Error Updating Database Php
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Error updating record in mysql database up vote 0 down vote favorite I am updating a mysql table. i am getting an error as below Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\test\edit.php on line 232 Error. 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 '' at line 1 The query seems not to be producing a result. I am passing an id to a function via a url but the variable seems to die although it seems to be in scope. What could be my error. The loop for the update is below. i have commented out some lines which i thought where a problem but they are fine. code in bold are the problem lines. elseif(isset($_POST['editSelection'])) { // check if form is submitted //collect variables posted by form. $fixture_id = mysql_real_escape_string($_POST['fixture_id']); $goalkeeper = mysql_real_escape_string($_POST['goalkeeper']); $defender = mysql_real_escape_string($_POST['defender']); $fullback = mysql_real_escape_string($_POST['fullback']); $midfielder = mysql_real_escape_string($_POST['midfielder']); $wing = mysql_real_escape_string($_POST['wing']); $striker = mysql_real_escape_string($_POST['striker']); $sid = mysql_real_escape_string($_POST['sid']); // receive the selection_id which was posted from the hidden field in the editForm $sql = "SELECT * FROM `selections` WHERE selection_id = {$sid}"; $data = mysql_query($sql); **while($rows = mysql_fetch_array($data)) { $opponents = $rows['opponents']; }** //validate form by checking for empty strings that user might have submitted using strlen() php built-in method. If no empty string form processes //if(strlen($fixture_id)>0 && strlen($goalkeeper)>0 && strlen($defender)>0 && strlen($fullback)>0 && strlen($midfielder)>0 && strlen($wing)>0 && strlen($striker)>0 && strlen($selection_id)>0) { // if form fi
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Error updating database PHP up vote 0 down vote favorite After submitting a http://stackoverflow.com/questions/16726011/error-updating-record-in-mysql-database payment form (credit cards, etc) to our payment gateway, we receive the "response_code" 1 when the payment is approved. We then use the following code to update a user's info in the database to reflect the approved transaction. However, about every 1 out of 10 times, a user's info simply will not update even though the transaction returned an approved response. Is anything clearly wrong with this code? Or perhaps http://stackoverflow.com/questions/7593537/error-updating-database-php the response_code does not equal 1 for some reason? php mysql session payment-gateway share|improve this question edited Sep 29 '11 at 7:30 asked Sep 29 '11 at 6:54 Mike 265 1 What stops me from setting ?response_code=1? Also, you might be open to SQL injection attacks! –Shef Sep 29 '11 at 7:41 add a comment| 2 Answers 2 active oldest votes up vote 2 down vote accepted Probably because there has been a session timeout? The WHERE uses the e-mail address, if this is not valid (not there) then you probably won't get an update. Maybe you should check for transaction ID (or similar). I guess you've got something like that before the transaction starts? edit: Also store if an error occurs, and try to store variables you need too. This makes it a lot easier to pinpoint the problem. Use a logfile for this for example. share|improve
PHP Data Types PHP Echo and Print PHP Strings PHP Operators PHP If…Else PHP Switch…Case PHP Arrays PHP Sorting Arrays http://www.tutorialrepublic.com/php-tutorial/php-mysql-update-query.php PHP Loops PHP Functions PHP GET and POST PHP ADVANCED PHP http://php.net/manual/en/mysqli.error.php Date and Time PHP Include Files PHP File system PHP File Upload PHP Cookies PHP Sessions PHP Send Email PHP Form Handling PHP Form Validation PHP Error Handling PHP DATABASE PHP MySQL Introduction PHP MySQL Connect PHP MySQL Create PHP MySQL Insert PHP MySQL Select error updating PHP MySQL Where PHP MySQL Limit PHP MySQL Order By PHP MySQL Update PHP MySQL Delete PHP EXAMPLES PHP Practice Examples PHP FAQ's Answers PHP REFERENCE PHP String Functions PHP Array Functions PHP File System Functions PHP Date/Time Functions PHP Calendar Functions PHP MySQLi Functions PHP Filters PHP Error Levels SPONSORED LINKS Unlimited Hosting $1.99/mo error updating database WordPress Hosting $3.75/mo Cloud Hosting Only $5/mo Advertise Here Tweet Follow PHP MySQL UPDATE Query The UPDATE statement is used to update the records in a MySQL database table. Updating Database Table Data The UPDATE statement is used to change or modify the existing records in a database table. It is typically used in conjugation with the WHERE clause to apply the changes to only those records that matches specific criteria. The basic syntax of the UPDATE statement can be given with: UPDATE table_name SET column1=value, column2=value2,... WHERE column_name=some_value Let's make a SQL query using the UPDATE statement and WHERE clause, after that we will execute this SQL query through passing it to the mysqli_query() function to update the tables records. Consider the following "persons" table inside the "demo" database: +-----------+------------+-----------+----------------------+ | person_id | first_name | last_name | email_address | +-----------+------------+-----------+----------------------+ | 1 | Peter | Parker | peterparker@mail.com | | 2 | John | Rambo | johnrambo@mail.com | | 3 | Clark |
Errors Exceptions Generators References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Context options and parameters Supported Protocols and Wrappers Security Introduction General considerations Installed as CGI binary Installed as an Apache module Session Security Filesystem Security Database Security Error Reporting Using Register Globals User Submitted Data Magic Quotes Hiding PHP Keeping Current Features HTTP authentication with PHP Cookies Sessions Dealing with XForms Handling file uploads Using remote files Connection handling Persistent Database Connections Safe Mode Command line usage Garbage Collection DTrace Dynamic Tracing Function Reference Affecting PHP's Behaviour Audio Formats Manipulation Authentication Services Command Line Specific Extensions Compression and Archive Extensions Credit Card Processing Cryptography Extensions Database Extensions Date and Time Related Extensions File System Related Extensions Human Language and Character Encoding Support Image Processing and Generation Mail Related Extensions Mathematical Extensions Non-Text MIME Output Process Control Extensions Other Basic Extensions Other Services Search Engine Extensions Server Specific Extensions Session Extensions Text Processing Variable and Type Related Extensions Web Services Windows Only Extensions XML Manipulation Keyboard Shortcuts? This help j Next menu item k Previous menu item g p Previous man page g n Next man page G Scroll to bottom g g Scroll to top g h Goto homepage g s Goto search(current page) / Focus search box mysqli::$field_count » « mysqli::$error_list PHP Manual Function Reference Database Extensions Vendor Specific Database Extensions MySQL MySQLi mysqli Change language: English Brazilian Portuguese Chinese (Simplified) French German Japanese Korean Romanian Russian Spanish Turkish Other Edit Report a Bug mysqli::$error mysqli_error (PHP 5, PHP 7)mysqli::$error -- mysqli_error — Returns a string description of the last er