Mysql Error Or Die
Contents |
Learn Bootstrap Learn Graphics Learn Icons Learn How To JavaScript Learn JavaScript Learn jQuery Learn jQueryMobile Learn AppML Learn AngularJS Learn JSON Learn AJAX Server Side Learn SQL Learn PHP Learn ASP Web Building Web Templates die(mysql_error()) Web Statistics Web Certificates XML Learn XML Learn XML AJAX Learn XML DOM how to print mysql error in php Learn XML DTD Learn XML Schema Learn XSLT Learn XPath Learn XQuery × HTML HTML Tag Reference HTML Event Reference HTML or die php Color Reference HTML Attribute Reference HTML Canvas Reference HTML SVG Reference Google Maps Reference CSS CSS Reference CSS Selector Reference W3.CSS Reference Bootstrap Reference Icon Reference JavaScript JavaScript Reference HTML DOM Reference jQuery Reference jQuery php mysqli error Mobile Reference AngularJS Reference XML XML Reference XML Http Reference XSLT Reference XML Schema Reference Charsets HTML Character Sets HTML ASCII HTML ANSI HTML Windows-1252 HTML ISO-8859-1 HTML Symbols HTML UTF-8 Server Side PHP Reference SQL Reference ASP Reference × HTML/CSS HTML Examples CSS Examples W3.CSS Examples Bootstrap Examples JavaScript JavaScript Examples HTML DOM Examples jQuery Examples jQuery Mobile Examples AngularJS Examples AJAX Examples XML XML Examples XSLT Examples XPath
Mysql Query Error
Examples XML Schema Examples SVG Examples Server Side PHP Examples ASP Examples Quizzes HTML Quiz CSS Quiz JavaScript Quiz Bootstrap Quiz jQuery Quiz PHP Quiz SQL Quiz XML Quiz × PHP Tutorial PHP HOME PHP Intro PHP Install PHP Syntax PHP Variables PHP Echo / Print PHP Data Types PHP Strings PHP Constants PHP Operators PHP If...Else...Elseif PHP Switch PHP While Loops PHP For Loops PHP Functions PHP Arrays PHP Sorting Arrays PHP Superglobals PHP Forms PHP Form Handling PHP Form Validation PHP Form Required PHP Form URL/E-mail PHP Form Complete PHP Advanced PHP Arrays Multi PHP Date and Time PHP Include PHP File Handling PHP File Open/Read PHP File Create/Write PHP File Upload PHP Cookies PHP Sessions PHP Filters PHP Filters Advanced PHP Error Handling PHP Exception MySQL Database MySQL Database MySQL Connect MySQL Create DB MySQL Create Table MySQL Insert Data MySQL Get Last ID MySQL Insert Multiple MySQL Prepared MySQL Select Data MySQL Delete Data MySQL Update Data MySQL Limit Data PHP - XML PHP XML Parsers PHP SimpleXML Parser PHP SimpleXML - Get PHP XML Expat PHP XML DOM PHP - AJAX AJAX Intro AJAX PHP AJAX Database AJAX XML AJAX Live Search AJAX RSS Reader AJAX Poll PHP Examples PHP Examples PH
and Objects Namespaces Errors Exceptions Generators References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes
Mysql_query Or Die
Context options and parameters Supported Protocols and Wrappers Security mysql_query error Introduction General considerations Installed as CGI binary Installed as an Apache module Session php mysql error handling Security Filesystem Security Database Security Error Reporting Using Register Globals User Submitted Data Magic Quotes Hiding PHP Keeping Current Features HTTP authentication with http://www.w3schools.com/php/func_misc_die.asp 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 http://php.net/manual/en/function.mysql-error.php 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 mysql_escape_string » « mysql_errno PHP Manual Function Reference Database Extensions Vendor Specific Database Extensions MySQL MySQL (Original) MySQL Functions Change language: English Brazilian Portuguese C
3 Connecting to a MySQL database from PHP 4 The 12 Days of PHP 5 10 Cool Things To Do With PHP About.com About Tech PHP/MySQL PHP with MySQL How can report MySQL errors into PHP? Robert Daly/OJO http://php.about.com/od/phpwithmysql/f/mysql_error.htm Images/Getty Images By Angela Bradley PHP/MySQL Expert Share Pin Tweet Submit Stumble Post Share By Angela Bradley Question: How can report MySQL errors into PHP?How can I receive feedback from MySQL when my PHP encounters a problem?Answer: https://www.sitepoint.com/community/t/mysql-query-dieing-with-no-error-message/73420 When you are working with PHP and MySQL and encounter an error, it is helpful to receive more detailed information regarding the problem to point you in the direction of fixing it. You can use the mysql error mysql_error ( ) to get feedback from MySQL to your PHP document if you are encountering problems. It is phrased as: mysql_error ( [link_identifier] )Here are some examples of how to utilize mysql_error ()mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error()) This will return an error if there is a problem connecting to your MySQL database $value = mysql_query($your_query) or die("A MySQL error has occurred.
Your Query: " . $your_query . "
Error: (" . mysql error or mysql_errno() . ") " . mysql_error()) When you encounter an error, this will return your custom message (A MySQL error has occurred.
) followed by a line number, and the actual error. Show Full Article Related How to close your MySQL connection from PHP Do you know how to close a MySQL connection? MySQL Connect Files in PHP How to Connect PHP Files to a MySQL Database More from the Web Powered By ZergNet Sign Up for Our Free Newsletters Thanks, You're in! About Today Electronics & Gadgets PHP/MySQL You might also enjoy: Healthy Eating Health Tip of the Day Sign up There was an error. Please try again. Please select a newsletter. Please enter a valid email address. Did you mean ? Thank you,,for signing up! PHP/MySQL Learn PHP - PHP Tutorial - Learn PHP Code Learn MySQL with free online tutorials Learn PHP - Advanced PHP - PHP Tutorial PHP & MySQL - Use PHP with MySQL - MySQL from PHP GD Library - PHP GD Library - GD Library Graphics PHP Functions - PHP Code - PHP Commands PHP and MySQL Security PHP and MySQL Basics - PHP and MySQL Info - PHP and MySQL Information Tools and Resources for PHP or MySQL. Troubleshoot PHP Errors - Fix PHP Errors - PHP Error Help Program
of it.... but it's the $result query that's a problem and the then if(!result) part seems unreliable. Love some suggestions. /// working fine......... $insert = mysql_query("INSERT INTO articles (id, title, body) VALUES ('','$_POST[title]','$_POST[body]')")or die( 'Error: ' . mysql_error()); $taggit1 = mysql_insert_id(); $tags = $_POST['tags']; $pieces = explode(",", $tags); foreach ($pieces as $l){ $l = trim($l); /// echo's out - so I have a value. echo $l; //////// this query dies and kicks up no error //////// $result = mysql_query("SELECT id FROM tags WHERE tag = '$l'"); $row = mysql_fetch_array($result)or die( 'Error: ' . mysql_error()); ///if there is a result here I'm good. $taggit2 = $row[0]; //// there isn't always anything in the database so sometimes we have no result. //// if (!$result) { $insert2 = mysql_query("INSERT INTO tags (id, tag) VALUES ('','$l')")or die( 'Error: ' . mysql_error()); $taggit2 = mysql_insert_id(); echo 'there was no result - so I inserted a new tag'; } DarthGuido 2010-12-15 08:28:42 UTC #2 $result = mysql_query("SELECT id FROM tags WHERE tag = '$l'"); $row = mysql_fetch_array($result)or die( 'Error: ' . mysql_error()); Put the 'or die' part on the first line, and to have even more info show the actual query in the error message as well: $query = "SELECT id FROM tags WHERE tag = '$l'"; $result = mysql_query($query) or die( "Error: " . mysql_error() . " in query $query"); $row = mysql_fetch_array($result); stma 2010-12-15 08:31:42 UTC #3 guido2004: $result = mysql_query("SELECT id FROM tags WHERE tag = '$l'"); $row = mysql_fetch_array($result)or die( 'Error: ' . mysql_error()); Put the 'or die' part on the first line, and to have even more info show the actual query in the error message as well: php
$query = "SELECT id FROM tags WHERE tag = '$l'"; $result = mysql_query($query) or die( "Error: " . mysql_error() . " in query $query"); $row = mysql_fetch_array($result);
I wish it gave me more information. Just prints out the "Error:" text - and nothing further. Sorry I didn't include that in my example here, I'd stripped it out because I'd been playing around with it. DarthGuido 2010-12-15 08:38:08 UTC #4 stma said: Just prints out the "Error:" text - and nothing further. Did you try the changes I made? You can't get just "Error:" with my code. stma 2010-12-15 08:47:31 UTC #5 Thank you - I did get it working. I'm tired, can't believe I was looking at that the whole time and missed it. I'm having an issue with the if there is no result part: (!result) I think there must be a value there even when there is nothing to get.... but I'll deal with that in the morning after some sleep. Thanks.