php_silly Posted June 16, 2008 Share Posted June 16, 2008 Can anybody help me with my first few lines of codein php. I am trying to create a database in mysql using php but I am constantly getting errors. I am completely new so I cannot understand a thing. I was doing some online tutorials which gave me error. I get the access denied error. Please help Link to comment https://forums.phpfreaks.com/topic/110377-php-newbie-needs-help/ Share on other sites More sharing options...
bluejay002 Posted June 16, 2008 Share Posted June 16, 2008 please post your code. Link to comment https://forums.phpfreaks.com/topic/110377-php-newbie-needs-help/#findComment-566292 Share on other sites More sharing options...
PFMaBiSmAd Posted June 16, 2008 Share Posted June 16, 2008 You would need to post the code and the actual error message for anyone in a Forum to be able to help with the specific problem you are having. Based on the general information provided in your first post, the problem could be any of about a dozen different things. Link to comment https://forums.phpfreaks.com/topic/110377-php-newbie-needs-help/#findComment-566293 Share on other sites More sharing options...
php_silly Posted June 16, 2008 Author Share Posted June 16, 2008 I am sorry for not adding the code Actually, I was too stressed and did'nt think about adding code. Also, I was searching on net for tutorials when I came across it. At the moment I don't have it cuz I deleted it after getting frustrstred. I will search again and put it here. Thank you all for coming forward to help me Link to comment https://forums.phpfreaks.com/topic/110377-php-newbie-needs-help/#findComment-566709 Share on other sites More sharing options...
revraz Posted June 16, 2008 Share Posted June 16, 2008 You need to ensure you use the correct database information when you connect. It almost sounds like you used a ID that didn't have rights to do what you wanted to do. Link to comment https://forums.phpfreaks.com/topic/110377-php-newbie-needs-help/#findComment-566712 Share on other sites More sharing options...
php_silly Posted June 17, 2008 Author Share Posted June 17, 2008 This is the code that is giving me error. This code is from www.w3schools.com. After trying several times I thought they should update their tutorials. <?php $con = mysql_connect("localhost","peter","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } if (mysql_query("CREATE DATABASE my_db",$con)) { echo "Database created"; } else { echo "Error creating database: " . mysql_error(); } mysql_close($con); ?> Link to comment https://forums.phpfreaks.com/topic/110377-php-newbie-needs-help/#findComment-566969 Share on other sites More sharing options...
trq Posted June 17, 2008 Share Posted June 17, 2008 Mind letting us know what error it is your getting? Link to comment https://forums.phpfreaks.com/topic/110377-php-newbie-needs-help/#findComment-566974 Share on other sites More sharing options...
whizard Posted June 17, 2008 Share Posted June 17, 2008 You need to put in YOUR actual username/password... The values you are using are from the tutorial and are just examples. Dan Link to comment https://forums.phpfreaks.com/topic/110377-php-newbie-needs-help/#findComment-566989 Share on other sites More sharing options...
PFMaBiSmAd Posted June 17, 2008 Share Posted June 17, 2008 php_silly (and anybody else who reads this thread), programming is a very detail orientated activity. You might have heard the expression about needing to make sure your i's are dotted and your t's are crossed when it comes to doing and completing something that requires detailed work. Well in programming, where the figurative i's and t's are at, if they are capitalized or not, and if they are dotted and crossed correctly all matter in getting a program to do what you want it to. We only see the information that you provide in your posts. The exact wording in an error message indicates what specific problem is occurring. When you don't provide detailed information about what you see in front of you, you cannot really get a quick or accurate solution to your problem. Just stating that "I get the access denied error" is not detailed enough information when it comes to troubleshooting programming, because there could be 3-4 different things that could cause similar looking access denied errors. Link to comment https://forums.phpfreaks.com/topic/110377-php-newbie-needs-help/#findComment-566995 Share on other sites More sharing options...
DarkWater Posted June 17, 2008 Share Posted June 17, 2008 You used 'peter' and 'abc123' as your login credentials...those are the example ones in the default. Don't blame a perfectly fine tutorial for your errors. Link to comment https://forums.phpfreaks.com/topic/110377-php-newbie-needs-help/#findComment-567011 Share on other sites More sharing options...
bluejay002 Posted June 17, 2008 Share Posted June 17, 2008 if you are using a newly installed mysql server... then you have a super user you can freely try: username: "root" password: "" normally, when mysql is installed, a root user always exist that has no password at all. now if that is your case and its still untouched, then try it, it should work fine. Link to comment https://forums.phpfreaks.com/topic/110377-php-newbie-needs-help/#findComment-567044 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.