Jump to content

php newbie needs help


php_silly

Recommended Posts

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

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.

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 :)

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);
?>

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.