No Database selected why?


The code below says no database selected but there is what am I doing wrong

PHP Code: $db=mysql_connect("localhost","user","pass");\t

mysql_select_db('data');\t

$result=mysql_query("INSERTINTOtable(fname,lname,address,

city,province,postal,telephone,email,manufacturer,model,year,

kilometers,description,price,username,password)\t
\t\t\t\t\t\t\t\tVALUES('$fname','$lname','$address','$city',

'$province','$postal','$telephone','$email','$manufacturer',

'$model','$year','$kilometers','$description','$price',

'$username','$password')");\t
if(!$result)\t
{\t
\techo"Somethingnotadded:",mysql_error();\t
\texit;
Posted On: Monday 29th of October 2012 06:14:42 AM Total Views:  121
View Complete with Replies

RELATED TOPICS OF MYSQL PROGRAMMING LANGUAGE




can you point me to resources on database design? [was: Need Advice]

Greetings all, I am one humble php developer with enough knowledge of databases and sql to power my humble web applications. I was wondering if you could direct me to the resources on common practices about database design and how things should work efficiently. sites or articles would be greatly appreciated. I am planning to develop a site where there will be lots of users and lots of database manipulation and I want to know if I have been doing something wrong up untill now, or perhapes if there are better ways of doing things.. for example: people will post articles and others will rate it. To make sure user does not rate the article twice I have to save the info about the user rating the article.. userid, articleid, rating when I display multiple articles with it's rating I would have to calculate rating and find out how many people voted on thIs article. Should I do that all with sql and coaunt every time, or have an extra field with the article with number or votes and current rating (
VIEWS ON THIS POST

177

Posted on:

Monday 29th October 2012
View Replies!

Mysqldump - Unkown database - even thou the db exists

I have strange problem while trying to dump my database. The mysqldump just doesn't seem to find my database, even thou it works just fine with both command line tool, and with my java-application. Irrelevant stuff snipped out. Code: DRIVE:\bin>mysql -uroot -p Enter password: ******** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 62 to server version: 5.0.27-community-nt Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> show databases; +--------------------+ | Database | +--------------------+ | tolu | +--------------------+ 4 rows in set (0.00 sec) mysql> Then with my dump: Code: DRIVE:\bin>mysqldump -uroot -p tolu; Enter password: ******** -- MySQL dump 10.10 -- -- Host: localhost Database: tolu; -- ------------------------------------------------------ -- Server version 5.0.27-community-nt /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*SNIP SNIP*/ /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; mysqldump: Got error: 1049: Unknown database 'tolu;' when selecting the database Any ideas on this
VIEWS ON THIS POST

92

Posted on:

Monday 29th October 2012
View Replies!

What do you think of my database structure?

, I'm building a download site for paid members only and I log, at least according to me, quite a lot of things. I do also have the logs spread out on several tables so I'm wondering if I maybe have a "strange" database structure that will be hard to work with.. Here is it; Code: -- -- Table structure for table `downl_compl_logs` -- CREATE TABLE `downl_compl_logs` ( `downl_id` int(11) NOT NULL auto_increment, `downl_file_id` varchar(40) NOT NULL default '', `downl_file_fullname` varchar(30) NOT NULL default '', `downl_ip` varchar(30) NOT NULL default '', `downl_user` varchar(50) NOT NULL default '', `downl_refer` varchar(20) NOT NULL default '', `downl_status` varchar(30) NOT NULL default '', `downl_date` varchar(30) NOT NULL default '', `downl_timestamp` varchar(30) NOT NULL default '', PRIMARY KEY (`downl_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `downl_fail_logs` -- CREATE TABLE `downl_fail_logs` ( `downl_id` int(11) NOT NULL auto_increment, `downl_file_id` varchar(40) NOT NULL default '', `downl_file_fullname` varchar(30) NOT NULL default '', `downl_ip` varchar(30) NOT NULL default '', `downl_user` varchar(50) NOT NULL default '', `downl_refer` varchar(20) NOT NULL default '', `downl_status` varchar(30) NOT NULL default '', `downl_date` varchar(30) NOT NULL default '', `downl_timestamp` varchar(30) NOT NULL default '', PRIMARY KEY (`downl_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `files` -- CREATE TABLE `files` ( `file_id` int(11) NOT NULL auto_increment, `file_pack` varchar(50) NOT NULL default '', `file_pack_cat` varchar(50) NOT NULL default '', `file_cat` varchar(50) NOT NULL default '', `file_name` varchar(100) NOT NULL default '', `file_desc` text NOT NULL, `file_fullname` varchar(100) NOT NULL default '', `file_downloads` varchar(11) NOT NULL default '', PRIMARY KEY (`file_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -------------------------------------------------------- -- -- Table structure for table `ip_logs` -- CREATE TABLE `ip_logs` ( `ip_id` int(11) NOT NULL auto_increment, `ip_ip` varchar(30) NOT NULL default '', `ip_user` varchar(50) NOT NULL default '', `ip_latest_date` varchar(30) NOT NULL default '', `ip_latest_timestamp` varchar(30) NOT NULL default '', PRIMARY KEY (`ip_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `items` (Items that a user can buy) -- CREATE TABLE `items` ( `item_id` int(11) NOT NULL auto_increment, `item_name` varchar(100) NOT NULL default '', `item_identifi` varchar(100) NOT NULL default '', `item_price` varchar(30) NOT NULL default '', `item_file_name` varchar(100) NOT NULL default '', `item_file_pack` varchar(30) NOT NULL default '', PRIMARY KEY (`item_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `login_logs` -- CREATE TABLE `login_logs` ( `login` int(11) NOT NULL auto_increment, `login_user` varchar(50) NOT NULL default '', `login_ip` varchar(30) NOT NULL default '', `login_date` varchar(30) NOT NULL default '', `login_timestamp` varchar(30) NOT NULL default '', PRIMARY KEY (`login`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `sales` -- CREATE TABLE `sales` ( `invoice_id` int(10) NOT NULL auto_increment, `receiver_email` varchar(60) NOT NULL default '', `item_name` varchar(100) NOT NULL default '', `item_number` varchar(18) NOT NULL default '', `quantity` varchar(6) NOT NULL default '', `payment_status` varchar(10) NOT NULL default '', `pending_reason` varchar(10) NOT NULL default '', `payment_date` varchar(25) NOT NULL default '', `mc_gross` varchar(20) NOT NULL default '', `mc_fee` varchar(20) NOT NULL default '', `tax` varchar(20) NOT NULL default '', `mc_currency` varchar(4) NOT NULL default '', `txn_id` varchar(20) NOT NULL default '', `txn_id_refund` varchar(20) NOT NULL default '', `txn_type` varchar(10) NOT NULL default '', `payment_type` varchar(10) NOT NULL default '', `notify_version` varchar(10) NOT NULL default '', `verify_sign` varchar(10) NOT NULL default '', `referrer_id` varchar(10) NOT NULL default '', `memo` varchar(255) NOT NULL default '', `for_auction` varchar(20) NOT NULL default '', `auction_buyer_id` varchar(64) NOT NULL default '', `auction_closing_date` varchar(21) NOT NULL default '', `auction_multi_item` varchar(20) NOT NULL default '', `account_username` varchar(50) NOT NULL default '', `account_password` varchar(20) NOT NULL default '', `received_timestamp` varchar(20) NOT NULL default '', `first_name` varchar(30) NOT NULL default '', `last_name` varchar(40) NOT NULL default '', ` address_street` varchar(50) NOT NULL default '', `address_city` varchar(30) NOT NULL default '', `address_state` varchar(30) NOT NULL default '', `address_zip` varchar(20) NOT NULL default '', `address_country` varchar(30) NOT NULL default '', `address_status` varchar(11) NOT NULL default '', `payer_email` varchar(60) NOT NULL default '', ` payer_status` varchar(10) NOT NULL default '', `mark_paid` varchar(20) NOT NULL default '', `mark_shipped` varchar(20) NOT NULL default '', `mark_feedback` varchar(30) NOT NULL default '', `feedback_received` varchar(100) NOT NULL default '', `feedback_left` varchar(100) NOT NULL default '', PRIMARY KEY (`invoice_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `user_perm` (the files the user has permission to download) -- CREATE TABLE `user_perm` ( `perm_id` int(11) NOT NULL auto_increment, `perm_user` varchar(50) NOT NULL default '', `file_pack` varchar(30) NOT NULL default '', `file_name` varchar(100) NOT NULL default '', `perm_date` varchar(30) NOT NULL default '', `perm_timestamp` varchar(30) NOT NULL default '', PRIMARY KEY (`perm_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE `users` ( `user_id` int(11) NOT NULL auto_increment, `username` varchar(100) NOT NULL default '', `password` varchar(40) NOT NULL default '', `payer_email` varchar(100) NOT NULL default '', `ebay_userid` varchar(50) NOT NULL default '', `num_downloads` varchar(10) NOT NULL default '', `num_logins` varchar(10) NOT NULL default '', `num_ips` varchar(30) NOT NULL default '', `num_purchases` varchar(10) NOT NULL default '', `address_street` varchar(50) NOT NULL default '', `address_city` varchar(30) NOT NULL default '', `address_state` varchar(30) NOT NULL default '', `address_zip` varchar(20) NOT NULL default '', `address_country` varchar(30) NOT NULL default '', `address_status` varchar(11) NOT NULL default '', `payer_status` varchar(10) NOT NULL default '', `first_name` varchar(30) NOT NULL default '', `last_name` varchar(40) NOT NULL default '', `latest_login_date` varchar(30) NOT NULL default '', `latest_login_timestamp` varchar(30) NOT NULL default '', `created_date` varchar(30) NOT NULL default '', `created_timestamp` varchar(30) NOT NULL default '', PRIMARY KEY (`user_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; Feedback is appreciated : )
VIEWS ON THIS POST

221

Posted on:

Monday 29th October 2012
View Replies!

Emergency database recovery

becasue of a long story, i have mysql5 database files (ie files inside /var/lib/mysql) i also have a backup of the whole filesystem if its needed. anyways i need to recover this data in one way or another to insert into my new mysql server. is this possible how could i do this
VIEWS ON THIS POST

77

Posted on:

Monday 29th October 2012
View Replies!

Trying to create a donation tracking database

Here's what I have: 1 database dedicated to this project. 1 table named "amount" 1 field named "donation" An input form for the site owner to add donations to the database (tested and working, but...) I cannot show the output of the fields as a total. If I do a query, it simply lists the donations. I want to display only the total so far (I may at a later date add a display of "who donated what" but that is not a consideration for this project). Some details that may or may not matter: Apache version 1.3.37 (Unix) PHP version 4.4.3 MySQL version 4.0.27-standard
VIEWS ON THIS POST

110

Posted on:

Monday 29th October 2012
View Replies!

Implications of database page sizes

InnoDB's default database page size is 16K, but can be changed by recompiling the code to anywhere from 8K to 64K. My question has to do with what exactly a database page is, and what are the implications of its sizing I know very vaguely what a database page is, though it would be great if somebody reading this could explain it in their own terms. Also, what are the tradeoffs between having a smaller versus a larger database page size And what kinds of signs would alert a DBA as to the need to look into their database page size I hope somebody can point out these issues in detail.
VIEWS ON THIS POST

152

Posted on:

Monday 29th October 2012
View Replies!

Import CSV file into the MySQL database

Guys.. I have records into .CSV file and I want to import them into MySQL database. Whenever I import the .CSV I get the message Import has been successfully finished\t but only 79 out of 114 records will be inserted into the database. When I try to import the CSV file with 411 records, just 282 will be inserted. The CSV file which got 411 records includes two categories of records Active and Sold whereby 114 records are Active. Has someone gotten this type of problem If so what should be done
VIEWS ON THIS POST

75

Posted on:

Monday 29th October 2012
View Replies!

Small database with HUGE traffic 100 000/day... How to Optimize?

I have some data that I need to put inside a database and i'm wondering which way would be the fastest for the server/users. The data: 4 food groups,each with 3 sub-groups which have about 10-40 items with 3 "columns". Example: ================================== VEGETABLES AND FRUITS Dark green vegetables ID NAME QUANTITY ------------------------------------------------------------------ 1- asparagus 6 spears 2- avocado 1/2 medium 3- beans, green 125 ml, 1/2 cup 4- Broccoli 125 ml, 1/2 cup etc...... Orange vegetables ID NAME QUANTITY ------------------------------------------------------------------ 1- cantaloup 125 ml, 1/2 cup 2- carrots 125 ml, 1/2 cup 3- pumpkin 125 ml, 1/2 cup 4- yam 125 ml, 1/2 cup etc...... GRAIN PRODUCTS Whole grain ID NAME QUANTITY ------------------------------------------------------------------ 1- Barley 125 ml, 1/2 cup 2- Bagel 125 ml, 1/2 cup 3- Bread pita 125 ml, 1/2 cup etc...... Non-Whole grain ID NAME QUANTITY ------------------------------------------------------------------ 1- Bannock 125 ml, 1/2 cup 2- Bread, white 125 ml, 1/2 cup 3- muffin 125 ml, 1/2 cup etc...... ========================================= SO MY QUESTION IS : Considering there might be between 50 000 and 100 000 people per DAY accessing the form that fetches those item (with VERY simple queries), WHAT IS THE BEST WAY TO OPTIMIZE THE DATA (considering I want the site to be ULTRA FAST, and that NOTHING else than the PHP form will be on this site) --------------------------------------------- Here is what I thought : 1- make X number of tables for each "sub-group" with the 10-40 items in there with 3 columns (ID, NAME, QUANTITY) 2- make X number of tables for each "sub-group" with the 10-40 items in there with 2 columns (ID, NAME) and create a separate table for each sub-group just for QUANTITY 3- make 1 table with everything in and add a 4th column to define the "sub-group". Ex: 1-(ID)...cantaloup(NAME)...125 ml, 1/2 cup(QUANTITY)... Orange vegetable(SUBGROUP) 4- make 1 table with ID + NAME and 1 table with ID + QUANTITY + SUBGROUP 5- OR the database is so small it's not gonna affect anything; there are so much people on this site i just need a ultra fast server or a couple ones\t THANKS a lot and sorry for the length of the question... You rock
VIEWS ON THIS POST

48

Posted on:

Monday 29th October 2012
View Replies!

Loading a database schema in a Windows Environment

I am running MySQL 3.23.46 on my laptop (Win XP), and wondered how I go about loading a database schema Can this be done from the command prompt for instance, or is it easier to do so using PHP I have PHP 4 loaded.
VIEWS ON THIS POST

192

Posted on:

Monday 29th October 2012
View Replies!

Is FULTEXT search the best for my database query

i am building a travellers database. It contains a list of each coutry that a traveller has been to. The column for 'visited countries' will just contained the list of each country that the member has visited. My question is ; what is the best way to search that column for 'visited countries' . E.g if a member wants to search for all members who have visited the USA. i know that FULLTEXT searches will allow me to interate though the column to finding matching country names. However, i also understand that FULLTEXT has limits. for example, if the keyword search appears more than 50% then no result is returned . it's possible taht certain countries will indeed appear more than 50 % of the time; so how do i get aroud this. Is there an alternative search method or better way to search this column for matching countries. i am also concerned about speed. my country list wil ultimately contained millions of countries visited; will the FULLTEXT search be fast enough to return the results Thank you for your kind attention. warm regards Andreea , Quote: Originally Posted by andreea115 I am using MQSQL could you please spell that out in words, i've never encountered that particular acronym Quote: Originally Posted by andreea115 i am not 100 per cent sure i understood what you meant. you have a members table, right with a column for visited countries perhaps if you could show the CREATE TABLE statement for that table, i'll show you how to normalize the countries column for further background, do a search for first normal form
VIEWS ON THIS POST

141

Posted on:

Monday 29th October 2012
View Replies!

Need a template database, where to find it?

all, I am trying to learn MySQL. And I am in need of a readymade database which I can use to experiment learning SQL/MySQL. I am familiar with importing csv files or sql dumps. Is there one such database out there already that I can use TIA
VIEWS ON THIS POST

92

Posted on:

Monday 29th October 2012
View Replies!

Looking for free databases to use in MySQL

Does anybody know a good online source of dummy databases Ideally something in excel/CSV/Open Office Spreadsheet format I'm trying to learn MySQL and would like some data to experiment on/perform commands on/manipulate using MySQL commands. Cheers! Miktor
VIEWS ON THIS POST

202

Posted on:

Monday 29th October 2012
View Replies!

Migrate a few small databases from RH9 to FC5

I don't have a lot of experience in MySQL. Just enough to use it occasionally. I have an older Red Hat 9 system running MySQL. It has about 6 databases, not very large. A few hundred records each. I don't know the structure of these databases. I inherited these projects with all the ids and passwords. I have a new Fedora Core 5 system running MySQL. How do I: 1. Get all databases out of MySQL on RH9. (I'll scp them over to FC5.) 2. Push all the databases into MySQL on FC5. 3. Preserve everything, all the ids and passwords, etc.
VIEWS ON THIS POST

75

Posted on:

Monday 29th October 2012
View Replies!

Values in Insert statement not inserting into database

I have an Insert sql statement where it is working fine with one exception. The date column keeps getting the default value of 0000-00-00 when I try to insert a date: Code: INSERT INTO `specials` ( `title` , `special`, `exp`, `price`, `image`, `shop` ) VALUES ('Radiator Flush', 'Complete flush of cooling system...', '2006-28-6', '49.99', 'radiator.jpg', '77') Here is the sql from phpMyAdmin that results in the exp value getting inserted: Code: INSERT INTO `specials` ( `id` , `title` , `special` , `exp` , `price` , `image` , `shop` ) VALUES ('', 'Test', 'Test Test', '2006-06-30', '59.95', 'tom.jpg', '77'); So in conclusion, the first sql statement (mine) results in the exp field getting a value of 0000-00-00; the second sql statement from phpMyAdmin gets all values as it should. Here is my table structure: Code: CREATE TABLE `specials` ( `id` int(10) NOT NULL auto_increment, `title` varchar(100) NOT NULL default '', `special` text character set ascii NOT NULL, `exp` date NOT NULL default '0000-00-00', `price` double NOT NULL default '0', `image` varchar(50) NOT NULL default '', `shop` int(4) NOT NULL default '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=16 ;
VIEWS ON THIS POST

103

Posted on:

Monday 29th October 2012
View Replies!

How to put data from a autogenerated string into database without using a form

I want to put a random generated password in a database: I wrote this code: Code: Now I want to put this password into a database: Code: $query = "INSERT INTO passwords (password) VALUES ('$password') WHERE handle ='$handle'"; mysql_query($query) or die("ERROR:".mysql_error()); $handle-data I get from a form for subscribers. Can anyone tell me what I'm doing wrong Thanx for help. Thoren
VIEWS ON THIS POST

141

Posted on:

Monday 29th October 2012
View Replies!

Updating/retrieving an Online MS Access database

. I'm producing a Macromedia/ Adobe Director application that uses an Access database file to share data amongst a network of pc's. I have this working with all the pc's networked in the office and sharing the database off a master pc. But ... The client has asked if their free roaming laptop can run the software & access the same data & I'm wondering if I can change the way things work & get the pcs & laptop to download the database in its entireity & then upload it again once the application's made changes to the data. From reading a few posts I dont think that getting it to continously access the database online will be fast enough so it would need to download & update locally somehow. Does anyone have any suggestions how to achieve this
VIEWS ON THIS POST

116

Posted on:

Monday 29th October 2012
View Replies!

Search one field in mysql databases for a phrase

i have a table with username and list as fields the list field contains a string that contains a lists of items, each one on a seperate line. is there any easier way to search the whole databases for a phrase conatined within the list field and have returned just the complete line where the phrase is and the username. without having to load each one and do a search on each entry hope so!! please advise how this might be done.
VIEWS ON THIS POST

123

Posted on:

Monday 29th October 2012
View Replies!

Find highest number in field WHERE userid=$userid in mysql database

please can someone tell me how i can do a mysql search something like this... i know the following is the wrong but it is to give you the idea of what i am trying to do. mysql_query("SELECT number FROM items WHERE userid='".$_SESSION['userid']."' AND number='the highest number in this field where the userid is $userid'"); can this be done using a method like this hope so :-)
VIEWS ON THIS POST

79

Posted on:

Monday 29th October 2012
View Replies!

Simple Banking database

Branch (BranchID, BranchPlace) Account (AccountID, AccountNumber, AccountType, Balance) Client (ClientID, ClientName, ClientSurname, ClientCity) Transaction (TransactionID, TransactionType, Amount) So i need defining primary keys and foreign keys, can anyone help me with this
VIEWS ON THIS POST

68

Posted on:

Monday 29th October 2012
View Replies!

Email contents of mysql databases

I have tried to get this to work with no luck as yet. What I have also tried is to use the command() function still nothing. Also tried the CronJob still nothing. How else can i back up the MySQL database. I am using Operating system Linux MySQL 4.1.18-standard-log phpMyAdmin 2.6.4-pl2 Can anyone help me out here please
VIEWS ON THIS POST

90

Posted on:

Monday 29th October 2012
View Replies!