We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
  • Pages:
  • 1
Quick question; on this mysql code
Topic Started: Dec 15 2005, 08:54 PM (878 Views)
MetallicaSk8er
<? echo"web-designer"; ?>
[ *  *  * ]
Yeah i am trying to connect to mysql and create a new database. Im not sure what is wrong with the code? can you help.
Code:
 
<?php
$sql = "CREATE database testDB2";
$connection = @mysql_connect("localhost", "haha", "hola") or die(mysql_error());
$result = @mysqlquery($sql, $connection) or die(mysql_error());
if ($result) {
$msg = "success!";
}
?>
<html>
<head>
<title>MySQL Connection</title>
</head>
<body>
<?php
echo "$msg";
?>
</body>
</html>


btw the password and username are random
Offline Profile Quote Post Goto Top
 
Dennis
Member Avatar
Member
[ *  *  *  *  *  *  * ]
What is the error you're receiving?
Offline Profile Quote Post Goto Top
 
MetallicaSk8er
<? echo"web-designer"; ?>
[ *  *  * ]
it doesnt have an error the screen is just blank, but when i try this
Code:
 
<?php
$connection = mysql_connect("localhost", "lala", "hola") or die(mysql_error());
if ($connection) {
$msg = "success!";
}
?>
<html>
<head>
<title>MySQL Connection</title>
</head>
<body>
<?php
echo "$msg";
?>
</body>
</html>


this is the error that comes up : Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\htdocs\connection.php on line 2
Offline Profile Quote Post Goto Top
 
ABeakyboy
Member Avatar
Computer wiz and freak
[ *  * ]
what version of PHP are you using? If you are using 5, you must manually enable the MySQL extension in the php.ini file.
Offline Profile Quote Post Goto Top
 
MetallicaSk8er
<? echo"web-designer"; ?>
[ *  *  * ]
yea how do u do that?
Offline Profile Quote Post Goto Top
 
Jory
Member Avatar
Member
[ *  *  *  *  *  * ]
You can see it by using phpversion() or phpinfo().
Offline Profile Quote Post Goto Top
 
MetallicaSk8er
<? echo"web-designer"; ?>
[ *  *  * ]
yea i have version five how did u say i enable it through the .ini file
Offline Profile Quote Post Goto Top
 
ABeakyboy
Member Avatar
Computer wiz and freak
[ *  * ]
Manuals are there that explain it.....

*ABeakyboy looks it up.

Ok here we go, thats the link to the documentation that explains it. Hope that helps ya :)


http://www.php.net/manual/en/ref.mysql.php


Edit: Unfortuately, that can be tricky to understand. If you tell us which OS it is, I MIGHT be able to give you a simple proceedure for doing it.
Offline Profile Quote Post Goto Top
 
MetallicaSk8er
<? echo"web-designer"; ?>
[ *  *  * ]
thanx i have windows
Offline Profile Quote Post Goto Top
 
bugmenot
Member
[ * ]
W!nd0w$?

Well, can't help you but the query wont work anyway, it's mysql_query not mysqlquery
Offline Profile Quote Post Goto Top
 
MetallicaSk8er
<? echo"web-designer"; ?>
[ *  *  * ]
hmm i still cant get it to work
Offline Profile Quote Post Goto Top
 
ABeakyboy
Member Avatar
Computer wiz and freak
[ *  * ]
Um, I need more information than that. Are you now getting an error message? Did you follow the instructions for enabling the MySQL extension in PHP?
Offline Profile Quote Post Goto Top
 
MetallicaSk8er
<? echo"web-designer"; ?>
[ *  *  * ]
yes i tried as best as i could to follow the instructions, and no i am not getting any message
Offline Profile Quote Post Goto Top
 
ABeakyboy
Member Avatar
Computer wiz and freak
[ *  * ]
Are you sure that PHP is set up correctly? If so, then $result must be equalling false or you would get something to appear. Make sure your query is correct.
Offline Profile Quote Post Goto Top
 
MetallicaSk8er
<? echo"web-designer"; ?>
[ *  *  * ]
yes it is setup right but ill work on sum stuff tonite, thanx for all ur help if u think of sumthin post please
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · Technology Chat · Next Topic »
Add Reply
  • Pages:
  • 1