!!!!! Posted July 5, 2007 Share Posted July 5, 2007 Okay, I have been trying out some MySQL stuff and, I cannot connect to MySQL. (Please don't call me stupid with this -->) I have thought that PHPMyAdmin was a MySQL Database, and I'm starting to think I was wrong. I don't know much about PHP but I'm trying to learn, and since I'm testing stuff out with MySQL, I really need to learn how to connect to it. Either A. Is PHPMyAdmin a MySQL Database (One of the reasons I think it isn't now is because it has 'PHP' in it instead of 'MySql' so I'm not totally stupid ( )) or B. Is there a way to check if I have a MySQL database? If PHPMyAdmin isn't a MySQL Database, can you please tell me where I can get a free MySQL Database and how I set it up. All you have to say is if I just Upload it to my FTP or if there's another way I must do it. Or, if PHPMyAdmin is a MySQL Database, can you please tell me how I find the port? I think I have my Username and Password right... As I log in with it into my PHPMyAdmin ON THE WEB THING. (Not through a PHP script, that's what doesn't work) Thanks! Please tell me if you need some more info to answer my question. Quote Link to comment Share on other sites More sharing options...
sKunKbad Posted July 5, 2007 Share Posted July 5, 2007 PHPMyAdmin is a simple interface for you to do stuff within MySQL. It isn't MySQL, it just helps you create databases, look into your databases, and modify them. Try installing WAMP5. It is a complete PHP / Apache / MySQL installation. Quote Link to comment Share on other sites More sharing options...
!!!!! Posted July 5, 2007 Author Share Posted July 5, 2007 PHPMyAdmin is a simple interface for you to do stuff within MySQL. It isn't MySQL, it just helps you create databases, look into your databases, and modify them. Oh, well is there a way I can find out my MySQL information, like the port, my Username, and my Password? I believe I know the Username and password, I'm just not sure about the port. In most cases I have tried 'localhost'. --- EDIT: Well, I'd like to find out if I have a MySQL Databse already before I download WAMP5. I have a database already in my PHPMyAdmin which leads me to think that I might have MySQL already installed. Quote Link to comment Share on other sites More sharing options...
!!!!! Posted July 5, 2007 Author Share Posted July 5, 2007 I can't seem to find anything on how to find this stuff... Does anyone have any answers please? Quote Link to comment Share on other sites More sharing options...
per1os Posted July 5, 2007 Share Posted July 5, 2007 find my.cnf should tell you what you need to know. If you know where mysql is installed to look at the data directory, that houses all the database plus tables inside those folders. Quote Link to comment Share on other sites More sharing options...
!!!!! Posted July 5, 2007 Author Share Posted July 5, 2007 find my.cnf should tell you what you need to know. If you know where mysql is installed to look at the data directory, that houses all the database plus tables inside those folders. Okay... Well, this file would be in my FTP right? Also, if I have to download MySQL, would I just Upload that to my '/public_html' folder in my FTP? Or is there multiple steps of how to install MySQL? Quote Link to comment Share on other sites More sharing options...
trq Posted July 5, 2007 Share Posted July 5, 2007 If your talking about a remote shared host you cannot install any software on such systems. What kind of hosting do you have? Or are you talking about your local machine? Quote Link to comment Share on other sites More sharing options...
NArc0t1c Posted July 5, 2007 Share Posted July 5, 2007 To connect to a database. mysql_connect('host','user','password') or die("Error: Connection Problem."); mysql_select_db('database'); PHPMyAdmin in a pice of software developed in php that work's with mysql. Scripting is totally PHP. How it stores data has to do with MySQL. (come to think of it, I really do not know how PHPmyadmin stores the actual data.. Google..) I suggest getting WAMP., it has Apache, PHP, MySQL, SQL Lite, PHPMyAdmin. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 5, 2007 Share Posted July 5, 2007 PHP is one of many scripting languages running on the server. MySQL is a database (among many) that stores data. phpMyAdmin is a set of PHP scripts allowing you to interface with the MySQL database. The other way of accessing MySQL is through a CLI (Command Line Interface) and is a pain in the neck to use. WAMP5 is a brilliant package that you can install onto your PC to turn it into a server for local work and is highly recommended unless you do what I do and upload scripts directly onto a remote server (web space!) and test/run them from there. If you have web space which supports PHP there's a good chance it already has MySQL installed. You can find this out by uploading this small script: <?php phpinfo(); ?> Once uploaded, access it and scroll down and it'll tell you what PHP has installed and if MySQL is installed. Before you can connect to a database you need to create one via phpMyAdmin (or from your own PHP scripts) and also create a user and give it access rights. Quote Link to comment Share on other sites More sharing options...
!!!!! Posted July 5, 2007 Author Share Posted July 5, 2007 find my.cnf should tell you what you need to know. If you know where mysql is installed to look at the data directory, that houses all the database plus tables inside those folders. PHP is one of many scripting languages running on the server. MySQL is a database (among many) that stores data. phpMyAdmin is a set of PHP scripts allowing you to interface with the MySQL database. The other way of accessing MySQL is through a CLI (Command Line Interface) and is a pain in the neck to use. WAMP5 is a brilliant package that you can install onto your PC to turn it into a server for local work and is highly recommended unless you do what I do and upload scripts directly onto a remote server (web space!) and test/run them from there. If you have web space which supports PHP there's a good chance it already has MySQL installed. You can find this out by uploading this small script: <?php phpinfo(); ?> Once uploaded, access it and scroll down and it'll tell you what PHP has installed and if MySQL is installed. Before you can connect to a database you need to create one via phpMyAdmin (or from your own PHP scripts) and also create a user and give it access rights. I have found my.cnf... It's file type is "SpeedDial"... Is that right? Also, I try connecting to my MySQL database with my PHPMyAdmin User and Pass, and it doesn't work. I'm going to try the phpinfo(). Quote Link to comment Share on other sites More sharing options...
!!!!! Posted July 5, 2007 Author Share Posted July 5, 2007 My MySQL info: I don't get how I can connect without a user or password? Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 5, 2007 Share Posted July 5, 2007 Are you running everything local on your machine or via web space? Secdond, do you have access to cPanel? Quote Link to comment Share on other sites More sharing options...
!!!!! Posted July 5, 2007 Author Share Posted July 5, 2007 Are you running everything local on your machine or via web space? Secdond, do you have access to cPanel? Eh, I have no clue... All I know is that I have FTP and stuff.. I think it runs on my computer, considering whenever I go to my website, it says "Connecting to <my ip>". I started using this Web Hosting when I didn't know any HTML and stuff so I stuck with a random one, called vDeck... Sorry, I never looked that far into it. All I know is I upload stuff to my FTP, and I have a Control Panel... Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 5, 2007 Share Posted July 5, 2007 If you have cPanel scroll down to where you see a section called "Databases" and there should be a link/button there called "MySQL" I'll try and grab a screenshot of my cPanel to make sure we have the same thing running... Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 5, 2007 Share Posted July 5, 2007 I don't get how I can connect without a user or password? install new sql then set the password as you desired^^ Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 5, 2007 Share Posted July 5, 2007 you must remember that whenever the sql has set password no way to bypass that stuff even in ftp Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 5, 2007 Share Posted July 5, 2007 http://img357.imageshack.us/img357/9916/cpanelej6.jpg Circled red is access to the MySQL databse so you can create databases and users. Circled green is a link to phpMyAdmin where you can admin your databases. Quote Link to comment Share on other sites More sharing options...
!!!!! Posted July 5, 2007 Author Share Posted July 5, 2007 http://img357.imageshack.us/img357/9916/cpanelej6.jpg Circled red is access to the MySQL databse so you can create databases and users. Circled green is a link to phpMyAdmin where you can admin your databases. In my database section (note i'm not using the same thing as you), it has options: either A. Setup or B. Admin. Admin takes me directly to PHPMyAdmin, and Setup let's me add databases. All my databases for some reason have to start with "neomoonc_"... Also let's me add users. Oh lol, so users let's me add users so I can access the database? <html> <body> <?php $host = "localhost"; $user = "--edited--"; $pass = "--edited--"; $con = mysql_connect($host,$user,$pass); if(!$con) { die('Could not connect: '. mysql_error()); } mysql_select_db("neomoonc_p_bb1",$con); $sql = "CREATE TABLE person ( firstname varchar(25); lastname varchar(25); age int; )"; mysql_query("INSERT INTO person(firstname,lastname,age) VALUES('$_POST[firstname]', '$_POST[lastname]', '$_POST[age]')); mysql_query($sql,$con); mysql_close($con);?> </body> </html> Mmm says there's an error on like 26... Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 5, 2007 Share Posted July 5, 2007 Yes. Once you add users to the database you must then assign permissions. Until you do this you won't be able to access the database using the user. The permissions are basically like the ability to create tables, drop tables, alter tables etc. You should also have the option to add all permissions which is what I use while developing a site. Once you have assigned permissions to a user you should then be given source in Perl and PHP to connect to the database using the user - just replace the default username and password with what you chose. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 6, 2007 Share Posted July 6, 2007 When posting connection code in public places, it's best to remove the username and password from your scripts. I'd go back and edit your post Quote Link to comment Share on other sites More sharing options...
!!!!! Posted July 6, 2007 Author Share Posted July 6, 2007 Yes. Once you add users to the database you must then assign permissions. Until you do this you won't be able to access the database using the user. The permissions are basically like the ability to create tables, drop tables, alter tables etc. You should also have the option to add all permissions which is what I use while developing a site. Once you have assigned permissions to a user you should then be given source in Perl and PHP to connect to the database using the user - just replace the default username and password with what you chose. It says I'm connected at --edited--@localhost, I put that port in the port spot in my code, and it's still not working. I made sure with the right username and everything. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 6, 2007 Share Posted July 6, 2007 mysql_query("INSERT INTO person (firstname,lastname,age) VALUES ('".$_POST[firstname]."', '".$_POST[lastname]."', '".$_POST[age]."')"); You forgot to unquote the end and I added spaces in the middle. Quote Link to comment Share on other sites More sharing options...
!!!!! Posted July 6, 2007 Author Share Posted July 6, 2007 When posting connection code in public places, it's best to remove the username and password from your scripts. I'd go back and edit your post Ya, , forgot about editing that out. I got no errors with that, but I sorta forget how to show stuff in a table. Could you give me a snippet of code to show the stuff in that table please? Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 6, 2007 Share Posted July 6, 2007 No need for this line near the end as you're trying to create another table called "people" mysql_query($sql,$con); Here's some code to read the table: <?php $query=mysql_query("SELECT * FROM people"); while ($fetch=mysql_fetch_assoc($query)) { echo $fetch['firstname'].' '.$fetch['lastname'].' is '.$fetch['age'].'<br />'; } ?> That will go through all the rows and show the contents. Quote Link to comment Share on other sites More sharing options...
!!!!! Posted July 6, 2007 Author Share Posted July 6, 2007 No need for this line near the end as you're trying to create another table called "people" mysql_query($sql,$con); Here's some code to read the table: <?php $query=mysql_query("SELECT * FROM people"); while ($fetch=mysql_fetch_assoc($query)) { echo $fetch['firstname'].' '.$fetch['lastname'].' is '.$fetch['age'].'<br />'; } ?> That will go through all the rows and show the contents. Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/neomoonc/public_html/mysql.php on line 26 Also, I added these things together: <Html> <head> <title>MySQL Test</title> </heaD> <body> <form name="input" action="mysql.php" method="post"> <input type="text" name="firstname"><br> <input type="text" name="lastname"><br> <input type="text" name="age"><br> <input type="submit" value="submit"> </form> </body> </html> and <html> <body> <?php $host = "localhost"; $user = "--edited--"; $pass = "--edited--"; $con = mysql_connect($host,$user,$pass); if(!$con) { die('Could not connect: '. mysql_error()); } mysql_select_db("neomoonc?p?bb1",$con); $sql = "CREATE TABLE person ( firstname varchar(25); lastname varchar(25); age int; )"; mysql_query("INSERT INTO person (firstname,lastname,age) VALUES ('".$_POST[firstname]."', '".$_POST[lastname]."', '".$_POST[age]."')"); ?> <?php $query=mysql_query("SELECT * FROM people"); while ($fetch=mysql_fetch_assoc($query)) { echo $fetch['firstname'].' '.$fetch['lastname'].' is '.$fetch['age'].'<br />'; } ?> <?php mysql_close($con); ?> </body> </html> And they won't add any tables or fields. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.