SELECT Error: No Database Selectedin Query: SELECT * FROM Schedule
I got the above error message after reading FAQ #10 which applied to my first error. The thing is, I thought I had selected a database. This script is copied from a tutorial, and I'm just too new at this to spot my error. PHP Code:
View Complete Forum Thread with Replies
Related Forum Messages:
Multiple Select From Listbox And Execute A Sql Query Select Statement
Supposing i have a html form with 2 listbox and i name it status and resolution. So it goes <select name='status[]'>... <select name='resolution[]'> Then i have a another php page. $status = $_POST['status']; $resolution = $_POST['resolution']; Now my question is, how do i do the sql query statement? mysql_query("SELECT * from bugs where status=$status and resolution=$resolution"); The problem is, i select 3 options form the status listbox eg. new, closed, duplicate. And from the resolution, i chose fixed, invalid.
View Replies !
Running My Select Query Database
i have a html form called connect.html where i enter my username and password. I then click the submit button and if i am successful it will go to my handler1.php file which will displays User [w1009048] successfully connected table is a page to my table.php pagef. When they click on the word table(link to table.php) i am running a select statment against my database: Code:
View Replies !
Select Database Error
i cant seem to find the error in this code: $db = mysql_connect($dbHost, $dbUsername, $dbPassword) or die("connection failed"); $db_select = mysql_select_db($databasename, $db) or die("no selection"); i have checked the variables above. if there was no such database, would it return an error such as "no database in MySQL"?
View Replies !
Error In Query: SELECT Uid, Uperms From Users WHERE Uname =
I am trying to set up the article from the main page in devshed called money is time the thing is this, it denies access for this user and pass even though they are in the database 'example' and on table (users) Error in query: SELECT uid, uperms from users WHERE uname = 'john' AND upass = PASSWORD('john'). Access denied for user: '@localhost' to database 'example' Code:
View Replies !
Error In Generating Table From Database Select Statment
I am trying to dynamically create a table with the results from a select statement. Below is the code that is not working. Any help would be oh so greatly appreciated. This is for a final at school which is due in an hour. This is the only thing I can't seem to make work. Code:
View Replies !
Execute An Update Query Based On The Results Of A Select Query
I'm trying to execute an update query based on the results of a select query... This doesn't work - any ideas? This is the code I'm trying to get to run (it updates all products which are set to arrive by a certain date if that date has arrived or passed - and there are products that should and should not be updated in the db this is being tested with...): Code:
View Replies !
Turn Select Query Result Into Hyperlink To Other Query
I have a query which gives results of selecting coursenames from a table called trainingtopics but this does so in a continuous bulk of text without any breaks between each record. my question how do I create line breaks between each record and also how can I force each query result to become a hyperlink which when clicked runs another query that gives details of that course. <?php $user = "root"; $host = "localhost"; $password = ""; $connection = mysql_connect($host, $root, $password) or die ("Couldn't connect to server."); $database = "courses"; $db = mysql_select_db($database) or die ("Couldn't select database."); $sql = "SELECT coursename FROM trainingtopics"; echo $sql."=sql<br>"; $result = mysql_query($sql) or die(mysql_error()); echo $result."=result<br>"; while($row=mysql_fetch_array($result)) { // NOTE this one ABOVE the echo echo "result found!"; echo $row[0]; } ?>
View Replies !
Select Query With And / Or
Trying to get a search feature running. A table has 2 field 'itemname' and 'itemdescription'. I would like the search to use a keyword on both of these fields but i'm unsure of how to seperate it from the main query. $query = "SELECT " .sellerid . "," . itemname . "," . itemtype . "," . itemstate . "," . itemprice . "," . pic1 . "," . itemid . "," . itemdescription . " FROM item where " . itemtype . "= '$ctype' AND " . itemstate . " like '$stype' AND " . itemprice . " >= '$lprice' AND " . itemprice . " <= '$hprice' AND " . itemdescription . " like '%$kwords%' OR " . itemname . " like '%$kwords%' ORDER BY `itemprice` DESC LIMIT $offset, $rowsPerPage"; The OR seems to be working on the whole query not just the last little bit like i would wish. " . itemdescription . " like '%$kwords%' OR " . itemname . " like '%$kwords%' Something like this but contained in the main query? Does this make sense?
View Replies !
Select * From Query
Im trying to run a simply Select * from query but the result is a blank page. here is my code. when I connect to the db using the same code but inserting data I get no problems. so Im having no server problems. <?php $user = "root"; $host = "localhost"; $password = ""; $connection = @mysql_connect($host, $root, $password) or die ("Couldn't connect to server."); $database = "courses"; $db = @mysql_select_db($database, $connection) or die ("Couldn't select database."); $sql = "SELECT * FROM trainingtopics"; or die (mysql_error()); ............................
View Replies !
Query SELECT * FROM
here is my query to my database $result_pi = mysql_query("SELECT * FROM players WHERE teamid = '".$gm_team2."' AND position != 'G' and status = 'Healthy' AND registered = Ƈ' ORDER BY lname"); this works fine, but i am trying to add in as well status = 'Rookie' When i try and add this, both the status things work against each other. How can I get this query to bring up both of them.
View Replies !
Select Query
However when I echo mysql_num_rows it gives 0 results even though the same date is in the db table. class_date is set as date type in mysql db. PHP Code: $query = "SELECT * ". "FROM class ". "WHERE class_date = $class_date";
View Replies !
Select Query
I have a table with 2 fields, lets say field1 and field2: Now I have records in that table something like this: 1 a 1 ab 2 a What I need is to make a selection and the result returned to be something like this: 1 a;ab 2 a So, I want for the same field1 to concat field 2 using a separator (ex. ‘;’). Mysql server version is 4.0.
View Replies !
Mysql Query - Select Any
I have the following sql statemant to search a mysql database that gets if values from a form with combo box's in. SELECT * FROM hottubs, manufacturers WHERE manufacturers.manid = hottubs.manid AND hottubs.type = '%s' AND hottubs.dimlength <= '%s' AND hottubs.dimwidth <= '%s' AND hottubs.dimhight <= '%s' AND hottubs.seatsto <= '%s' AND hottubs.shape = '%s' ORDER BY $thesearchtype_search. Everything works fine except I want to add a select "any" from the shape combo box. I really need a way of cutting out the last " AND hottubs.shape = '%s' " if the $_GET['shape'] = 'any' Will this work using a variable as shown below?? IF ($_GET['shape'] != 'any' ) { $shape = AND hottubs.shape = '%s' } SELECT * FROM hottubs, manufacturers WHERE manufacturers.manid = hottubs.manid AND hottubs.type = '%s' AND hottubs.dimlength <= '%s' AND hottubs.dimwidth <= '%s' AND hottubs.dimhight <= '%s' AND hottubs.seatsto <= '%s' $shape ORDER BY $thesearchtype_search I have only been doing php about a month so go gentle!
View Replies !
Select Query Problem
I use php4 and winxp. This query works as expected: $result = mysql_query(" SELECT feventid, UNIX_TIMESTAMP(fdate) as fdate, ftitle, fpostedby, fdetails, factive, UNIX_TIMESTAMP(fpostdate) as fpostdate FROM events WHERE fdate between '$datefrom' and '$dateto' and factive and fpostdate <= curdate() ORDER BY fdate, fpostdate "); However, when I add the condition !(strpos(fdetails,'$fsearchstring')===false), $result is false. $result = mysql_query(" SELECT feventid, UNIX_TIMESTAMP(fdate) as fdate, ftitle, fpostedby, fdetails, factive, UNIX_TIMESTAMP(fpostdate) as fpostdate FROM events WHERE fdate between '$datefrom' and '$dateto' and factive and fpostdate <= curdate() and !(strpos(fdetails,'$fsearchstring')===false) ORDER BY fdate, fpostdate "); Even simpler stuff like: 'and strpos('abc','c')>0' does not work. I made two more discoveries trying to crack the problem. Ɔ=0', is an acceptable condition, while 'true' is not. For the first query, $result does not return true, but 'Resource id #3'. I have just started with php. What am I doing wrong?
View Replies !
Select Query For Keywords
I am connecting to an Access database. I have the following code that breaks the user submitted title into an array. I want to match only records that have only the array values, but can be in any order. For example: User enters - "Purple People Eater" Matching Records - "Purple Eater People", "Eater People Purple",... but NOT - "The Purple People Eater", "Purple People",... Here is my code: PHP Code:
View Replies !
Select Query / Loop
My users are organised in a table named 'users'. Each user is a member of a department, but some users are members of more than one department, so I have another table named 'user_department'. I have another table named 'submissions' int which users submissions are stored. Right now I am developing an archive of submissions. Generally speaking a simple query will do the job like this: $query = "SELECT * FROM submissions WHERE status != 'Pending' AND sid = '$username' ORDER BY id desc LIMIT $from, $max_results"; $result = mysql_query($query); The problem comes when I try to select only the submissions lodged by the users department. The point being that the department head can view all submissions lodged by his department. If the department head is only head of a single department, this would work: $query = "SELECT * FROM submissions WHERE status != 'Pending' AND department = '$users_department' ORDER BY id desc LIMIT $from, $max_results"; $result = mysql_query($query); But if the department head is head of more than one department, I start to get lost! I can loop through the 'user_department' table to find out which departments the user is the head of like this: Code:
View Replies !
Php Query To Select Min Date
im trying to get a minimum date from my database, the current way im doing it is: SELECT * FROM events where Date > NOW() OR Date = '9999-12-12' ORDER BY Date ASC LIMIT 1 this works in terms of code, but it doesnt do what I want it to do. Its the ORDER BY Date, that is the problem: What I want to select is The next date OR a date = 9999-12-12 I tried searching for a query like "select MIN date" but couldnt find anything on it, plus the date has to be in the future, hence the need for DATE > NOW() quite confusing I know!! but any advice?
View Replies !
Select Menus Query
I have created numerous select menus where the user can if they so wish select all or any one of them. At the moment my code insists that they always select at least the subfund menu. How can I set it up so that they can select any one menu? Code:
View Replies !
Problem With Select Query
This script/function tests properly when using DreamWeaver's Testing Server and Live Data Settings, but fails on the live Web Server, giving the following error. Code:
View Replies !
Mysql Select Query With Php
I want to create a sql query but don't know if this is possible with mysql. The Query should do the following: Select all db entries from table in which entry a is smaller than the number (count) of all db entries with criteria x from another table.
View Replies !
Select Query + Inner Join
I have 2 tables: keywords{keyword_id, keyword} url{url_id, url, keyword_id} I have a search form where the user enters a keyword and if it is similar to the keyword(s) in database it should return the url. Code:
View Replies !
Reconfigure A Select Query
have a query that I want to display in a table format on a web page. I call up the following recordset. Name, Color and Rank are the fields. The results of the query are: Name -Color -Rank Jim--Orange --1 Bob-- Red ---1 Sue --Blue ---1 Jim--Yellow --2 Bob- Green --2 Sue -Purple-- 2 I want to reconfigure the above results to display in a table format as follows: Rank- Jim -Bob -Sue 1 - Orange--Red- --Blue 2 --Yellow -Green- Purple Notice that I want the individual names to be the column headings. I'm not sure how to approach it. Another forum recommended converting the query into an array, but after much head banging and research I'm not sure how to do it.
View Replies !
Select And Update In One Query
If I have a simple select query that select everthing in a row like SELECT * FROM profiles WHERE ..... can I also make a update in conjunction with the selection? Like 'column+1' so I will get a field telling me how many times a specfic rowID has been viewed? What about speed? Is there any difference in running two queries right after each other or running one query with a combined select/update?
View Replies !
Select Query From 2 Tables
I have 2 tables, both of which contain a feild which holds an id number. table = int_bookings feild name = booking_id, TYPE =int feild name = course_id, TYPE = int table int_courses feild name id, TYPE = int I want to call records from the "int_bookings" table using the "booking_id" and show all the feilds along with the record from the "int_courses" that has the same "course_id". Code:
View Replies !
Multiple Select Query
I'm trying to make a page where you can view all users or narrow them down by country. The problem I'm having is selecting several countries. In other words intead of finding users from either country 1 or country 2 I want to be able to see users from countries 1,3,4,9,32. Code:
View Replies !
Select Distinct In Sub Query
A very simplified version of one of my database tables looks like this: city_pairs ( pairid, city1, city2 ) The city_pairs table contain cities in pairs where a pair may occur twice: row 1: city1: 'new york', city2: 'new mexico' row 2: city1: 'new mexico', city2: 'new york' This is expected behaviour. Now I need to select the pairid of all pairs, but I want unique pairs. Ie, in the example above I want only the firs row. How can I do this? I tried something like: Code:
View Replies !
Query - Select *, DATE_FORMAT
I cant figure out what is wrong whith this query: select *, DATE_FORMAT(a_date, '%m/%d/%Y') as a_date_formatted from company, activity where c_id=a_c_id and medivas ='$poc' and priority ='$prioritya' and priority ='$priorityc'
View Replies !
Mysql Select Query
PHP Code: <?php include 'common.php' include 'db.php' if(!isset($_POST['register'])) { header("Location=register.php"); } else { dbconnect('rishaorg_members'); } if($_POST['newid']=='' or $_POST['firstname']=='' or $_POST['lastname']=='' or $_POST['address']=='' or $_POST['city']=='' or $_POST['state']=='' or $_POST['country']=='' or $_POST['birthcity']=='' or $_POST['birthstate']=='')........
View Replies !
MySql Query With SELECT
The following query used to work on older PHP. I have upgraded to PHP 4.3.2 and now it stopped working. No problems connecting to db can even print the variables used for search. But it seems as if the variables aren't presented to the query: $result = mysql_query("SELECT username, name, surname, email FROM forums_auth WHERE username ='$_POST[pnr]' OR name LIKE '$_POST[fnavn]' OR surname LIKE '$_POST[enavn]' ORDER BY surname, name ASC") OR DIE ( mysql_error() );
View Replies !
Multiple SELECT COUNT()'s In One Query?
I'm creating a script that, fairly often throughout, I need to use a SELECT COUNT() query on two seperate tables - this seems to be slowing the script down quite a bit, and if the script remains this slow, it won't be of much use to me...which would be very bad! Is there anyway to combine these two to grab the COUNT() value from both in one query?
View Replies !
Pass Array Into Select Query ?
I was wondering if it is possible to pass a php array into a mysql query rather than looping through each one eg: //the array $namesArray = array("Joe", "Jane", "Bob", "Mary", "Paul", "Eddie", "John"); //the sql SELECT id FROM users WHERE name='$namesArray'
View Replies !
Arrays, Query Results And Select Box
I want/need to pre-select a drop-down box with a value if it's present in both a lookup table and user account table. After wrestling with this for a few hours I give up. i know this can't be this complicated, but apparently i'm missing something, so if anyone can suggest a way to go about this i'd be a little more sane. The idea is to have the user value already selected then when they change the value i'll update their account.
View Replies !
How To Corret This Mysql Select Query?
I convert some code from access to mysql. And I have a InboxMessage table which has From and To field. So, the query is like: select * from InboxMessage where To=12 12 is user id. This query works fine in access. But does not work in Mysql. I think the problem is the field To, which must be a keyword in mysql. So, how to fix this? I don't want to change the field, becuase this will need to change a lot of code.
View Replies !
Merging 2 Tables With A Select Query?
I have two tables in my database. One is called 'hotfood', the other is 'coldfood'. What I want to do is have a single SELECT query for both of these tables. This is so I can then use 'mysql_num_rows' on this query, like so. if(mysql_num_rows($id)==0) { print "Food type does not exsist"; } else { -- } It basicaly to do a search type thing, the above checks that the food name exists by checking both the hot and cold food table, therefore I need to two merged into the select query so that I can search it.
View Replies !
$query="SELECT Max(timestamp)
can anyone help with this code? <?php $query="SELECT max(timestamp) FROM users_logins WHERE username='$session->username'"; $result=mysql_query($query) or die(mysql_error()); echo $result; ?> The result is: "Resource id #14" and it have to be "1148052356", and if i make the query in a mysql program it show the right result.
View Replies !
Is There A MySQL Function Within The SELECT Query....
Is there a mySQL function within the SELECT query that can add all of the data within a field. For example if I have a table called "profiles" and a field within that table called "referals" (which is an integer) and I wanted to add all of the results within that field together... I was trying to think of a loop to write this code in and may still do it but was wondering if there is a function within the SELECT statement that can ADD all of them together.
View Replies !
SELECT Query Syntax Problem
I have a couple of databases I'm working from. they are listed below : Code: REPORTS ******* IDFLTIDNOTES ------------------------- 12Flight 20 21Flight 10 31Flight 10 43Flight 30 51Flight 10 62Flight 20 FLIGHTS ******* IDNUMTOFROMDIST ------------------------------------- 110KLAXKSFO238 220KSEAKLAS409
View Replies !
Manipulating Result On A SELECT Query
I have the following table: +-------------------------+ | id | tid | type | value | +-------------------------+ | 1 | 23 | 1 | 8 | | 2 | 21 | 1 | 6 | | 3 | 21 | 2 | 4 | | 4 | 21 | 2 | 9 | | 5 | 22 | 2 | 9 | | 6 | 22 | 1 | 10 | | 7 | 23 | 1 | 5 | | 8 | 22 | 1 | 4 | | 9 | 21 | 2 | 7 | | 10 | 22 | 2 | 7 | +-------------------------+ and I want to get the result like this: Code:
View Replies !
SELECT Query With Information From Other Columns
Table_1 contains name column and yes/no column Table_2 contains name column and number column Typical rows from Table_1: John, yes Bill, no Pete, yes Typical rows from Table_2: John, 2 John, 435 John, 34 Bill, 234 Bill, 19 Here is my question - I want to run a query that says if Table_1 yes/no column = no, then ignore that person. And, if Table_1 contains yes, but the person is not found in Table_2, then ignore that person. Else return people in a SELECT query with information from other columns in both Table_1 AND Table_2. Code:
View Replies !
Select (drop Down) Menu Query
I have a MySql table (meat) storing the results data of on online culinary exam. One of the fields in the record is "optype". It is a drop down select field with about 12 choices. I have a separate results page, and when a user goes to that URL the results are displayed automatically. I am currently displaying the results of the MySql table (meat) using the following query:: $query = "SELECT * FROM meat WHERE optype='Country_Club'ORDER BY time DESC"; Code:
View Replies !
Select Query Validation & Else Statement
Using GET and a simple SELECT query, I am selecting the url to a pic from the database. If no url is present in the db (ie no pictures have been uploaded) then the script should echo 'Photo not on file'. Seems that regardless of how I validate and echo the results, the script will echo the first condition of the if / else statement. When there is no pic url in the db instead of echoing 'Photo not on file' it echoes a blank image. Code:
View Replies !
|