Error Query Failed No Database Selected
Contents |
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 invalid query no database selected Stack Overflow the company Business Learn more about hiring developers or posting ads with php no database selected error us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a mysql no database selected community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up No Database Selected - PHP & MySQL up vote 7 down vote favorite 1 I no database selected error in php mysql am trying to connect to my database and when I run the code, I get an error. Can anybody tell me what is wrong also any errors in my PHP code? Thanks. Error: No database selected PHP Code: include('.conf.php'); $prof = $_GET['profile']; $prof = addslashes(htmlentities($prof)); $query = "SELECT * FROM aTable where id = '".mysql_real_escape_string($prof)."'"; $info_array = mysql_query($query, $con) or die (mysql_error()).; while($row = mysql_fetch_array( $info_array )) { echo $row['num1'];
No Database Selected Mysql Error
echo ""; echo $row['num2']; echo ""; echo $row['num3']; echo ""; echo $row['num4']; }; mysql_close($con); .conf.php file: php mysql share|improve this question edited Sep 22 '14 at 10:54 George Garchagudashvili 3,831102043 asked Dec 15 '11 at 0:02 Joe Torraca 63841841 3 mysql_select_db("aTable", $con); is aTable the name of your DB? sounds like a table name for some reason:) –thatjuan Dec 15 '11 at 0:04 1 Try putting an or die (mysql_error()); on the select_db() line to see if it outputs any errors. –Bojangles Dec 15 '11 at 0:04 Have you checked the return value of mysql_select_db() (i.e. $db) whether it is FALSE? –ChrisM Dec 15 '11 at 0:04 @JamWaffles the error is Access denied for user 'xxx'@'%' to database 'aTable' –Joe Torraca Dec 15 '11 at 0:07 @JosephTorraca There you have it then - you need to grant access to user xxx on database aTable –Michael Berkowski Dec 15 '11 at 0:10 | show 3 more comments 2 Answers 2 active oldest votes up vote 12 down vote accepted Unless you have the pa
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
Database Not Selected Error In Php
About Us Learn more about Stack Overflow the company Business Learn more about no database selected phpmyadmin hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss no database selected php mysqli 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 “no database selected” http://stackoverflow.com/questions/8513484/no-database-selected-php-mysql error even query is fine up vote 0 down vote favorite 1 I am new to mysql and php. I am working on database programming with php with mysql but getting "no data base selected" error continuously. I found this error quite famous on internet. I tried every answer which were given to others having the same problem but nothing worked. Here is my code: http://stackoverflow.com/questions/18033439/no-database-selected-error-even-query-is-fine if(!@mysql_connect('localhost','root','') || !@mysql_select_db ('a_database') ){ die ('Connection Error !'); } $query = "SELECT `food`,`calories` FROM `food` ORDER BY `id`"; if($query_run=mysql_query($query)){ while($query_row = mysql_fetch_assoc($query_run)) { $food = $query_row['food']; $calories = $query_row['calories']; echo $food.' has '.$calories.' Calories'.'
'; } } else { echo mysql_error(); } This is the code that gives error. After some search on net. I made some bit of changes, but the result was same. Changes that I made to first 3 to 4 lines: $link = mysql_connect('localhost','root',''); if(!$link || !mysql_select_db ('a_database', $link) ){ die ('Connection Error !'); } Please tell me what should I do to get rid of this problem, Thank you. php share|improve this question asked Aug 3 '13 at 13:37 Muhammad Faraz 1,01041328 8 mysql_* is outdated, please use mysqli or PDO instead –Sliq Aug 3 '13 at 13:40 Why do you have an OR statement between $link and mysql_select_db, and what is with all the !, its definitely not easy to read. –Connor Tumbleson Aug 3 '13 at 13:40 1 sorry, but it is not my own style. i am following a thenewboston tutorial. –Muhammad Faraz Aug 3 '13 at 13:42 @Con
New? Today's Posts FAQ Rules Guidelines Search Advanced Search Forum :: http://www.codingforums.com/php/167452-php-query-no-database-selected-help-please.html Server side development PHP php query - no database selected??? help please!!! If this is your first visit, be sure to check out https://bugs.mysql.com/bug.php?id=25316 the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To no database start viewing messages, select the forum that you want to visit from the selection below. Enjoy an ad free experience by logging in. Not a member yet? Register. Page 1 of 2 12 Last Jump to page: Results 1 to 15 of 21 Thread: php query - no no database selected database selected??? help please!!! Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Rate This Thread Current Rating Excellent Good Average Bad Terrible 05-28-2009,05:24 PM #1 LJackson View Profile View Forum Posts Visit Homepage Senior Coder Join Date Jun 2008 Location Cornwall Posts 2,126 Thanks 300 Thanked 12 Times in 12 Posts php query - no database selected??? help please!!! Hi All, ok i am displaying all my items from my table stores like this PHP Code: Balint Email Updates: Status: Closed Impact on me: None Category:Connector / ODBC Severity:S2 (Serious) Version:5.00.10 OS:Microsoft Windows (windows) Assigned to: Jess Balint Tags: ODBC5-RC View Add Comment Files Developer Edit Submission View Progress Log Contributions [28 Dec 2006 16:43] Jess Balint Description: Trying to issue a simple query from VB/ADO fails with: [MySQL][MyODBC 5.00.11][MySQL] 1046 No database selected How to repeat: Use this VB code (add Microsoft ActiveX Data Objects reference to project): Dim constring As String constring = "DRIVER={MySQL Connector/ODBC v5};server=localhost;uid=myodbctest;pwd=myodbctest;database=test;Option=3" Dim Con As ADODB.Connection Con = New ADODB.Connection Con.ConnectionString = conString Con.Open() Con.Execute("select * from xdata") [12 Jan 2007 13:00] Renato Gontijo I had the same problem on MySQL 5.0.27 with MyODBC 3.51.12 on Windows XP. I'm using VB6 and ADO 2.8. After connect to database with ADO is necessary to send command: Con.Execute("USE MyDATABASE;") With other versions of database like 5.0.22 this problem doesn't happen. I guess that some modification on connection routine made this error. I'm having problems to print reports with Crystal Reports XI with version 5.0.27. [13 Jan 2007 4:30] Laurensius Hermawi This error appeared again when I want to add or update data with this command Dim rs As ADODB.Recordset Set rs = New ADODB.Recordset rs.Open "SELECT * FROM tablename WHERE fieldname= 'XXX' ", Con, adOpenForwardOnly, adLockOptimistic rs!fieldname1="DDD" rs.update ---------- [24 Jan 2007 23:22] Jess Balint Problem with DSN-less connect string parsing. Fix committed in rev777. [18 Jul 2007 4:26] kudo edokawa mangwantong/ra I made authen to msql database by use ODBC 5 but i can not authen .because error Fails with "No database selected". what can i do?????? Legal Policies Your Privacy Rights Terms of Use Contact Us Portions of this website are copyright © 2001, 2002 The PHP Group Page generated in 0.021 sec. using MySQL 5.7.12-enterprise-commercial-advanced-log Content reproduced on this site is the property of the respective copyright holders.It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party. © 2016, Oracle Corporation and/or its affiliates $stores="SELECT*
FROMstores
WHEREcategory='$category'
ORDERBYstoreNameASC";
$query=mysql_query($stores);
while($row=mysql_fetch_array($query)){
$name=$row[