Jump to content

Recommended Posts

[code]<?php
    // ----------
    $host = "localhost";
    $user = "electri_ryan";
    $pass = "*********";
    // ----------
    mysql_connect($host, $user, $pass) or die("Error Connecting: ".mysql_error());
    $dbs = mysql_list_dbs();
    if(mysql_num_rows($dbs) > 0){
        while(list($db) = mysql_fetch_row($dbs)){
            if($db == "forums"){
                $exists = true;
            }
        }
    }
    if(!$exists){
        echo("Database does not exist!");
        // Create database...
        mysql_query("CREATE DATABASE `forums`");
    }
?>[/code]

Ok, when i run this code, no errors, and it echoes out "Database does not exist!", but when i look in cPanel, there is not a database calles forums...

Anybody know what is wrong? [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /]
Link to comment
https://forums.phpfreaks.com/topic/10506-create-database/
Share on other sites

Ok, i made a very simple test...

[code]<?php
    mysql_connect("localhost","electri_ryan","*********");
    mysql_query("CREATE DATABASE `forums`") or die(mysql_error());
?>[/code]

When i run this i get the error:

Access denied for user: 'electri_ryan@localhost' to database 'forums'

Do i have to set privileges or something? 'electri_ryan' has all privileges...
Link to comment
https://forums.phpfreaks.com/topic/10506-create-database/#findComment-39269
Share on other sites

[!--quoteo(post=377386:date=May 26 2006, 02:44 PM:name=Randy)--][div class=\'quotetop\']QUOTE(Randy @ May 26 2006, 02:44 PM) [snapback]377386[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Ok, i made a very simple test...

[code]<?php
    mysql_connect("localhost","electri_ryan","*********");
    mysql_query("CREATE DATABASE `forums`") or die(mysql_error());
?>[/code]

When i run this i get the error:

Access denied for user: 'electri_ryan@localhost' to database 'forums'

Do i have to set privileges or something? 'electri_ryan' has all privileges...
[/quote]
from 1 Noob to another Noob, if all you want to do is create a db; why not use the PHPMyAdmin from your CPanel. No point doing things the hard way.
Link to comment
https://forums.phpfreaks.com/topic/10506-create-database/#findComment-39333
Share on other sites

[!--quoteo(post=377386:date=May 26 2006, 02:44 PM:name=Randy)--][div class=\'quotetop\']QUOTE(Randy @ May 26 2006, 02:44 PM) [snapback]377386[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Ok, i made a very simple test...

[code]<?php
    mysql_connect("localhost","electri_ryan","*********");
    mysql_query("CREATE DATABASE `forums`") or die(mysql_error());
?>[/code]

When i run this i get the error:

Access denied for user: 'electri_ryan@localhost' to database 'forums'

Do i have to set privileges or something? 'electri_ryan' has all privileges...
[/quote]

I have noticed that some ISPs do not allow you to create databases this way. I am only taking a shot in the dark, but can you create a new database from phpMyAdmin? My current ISP does not allow me to do this (I'm sure it has something to do with a server configuration/setup that is beyond me). I can only create new databases within cPanel. Hopefully that explains your mystery, if not, I would love to hear the outcome.
Link to comment
https://forums.phpfreaks.com/topic/10506-create-database/#findComment-39438
Share on other sites

Hi

Is apache setup correct on you pc ?
Have you got a full white dial ?
can you connect and loginto phpmyadmin manualy?

let me know your results.

first these will need to be working as i noticed you are connecting to a localhost if you are connecting to a external server then this will need to be address with the correct connection data not localhost.


hope this helps.
Link to comment
https://forums.phpfreaks.com/topic/10506-create-database/#findComment-39476
Share on other sites

[!--quoteo(post=377602:date=May 27 2006, 05:14 PM:name=Randy)--][div class=\'quotetop\']QUOTE(Randy @ May 27 2006, 05:14 PM) [snapback]377602[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I am running this script on my server, not on my computer

i use localhost all the time for select, update, insert and such and it always works...
[/quote]

HI

If this is your server and on the same internet connection you would use something like 192.168.1.101 or localhost (no firewall or routed )(in your house)
for example

if your server is running from somewhere else in the world (one you are paying for)you would use there connection address.wwwservername.co.uk

which one is it ?

cheers.

Link to comment
https://forums.phpfreaks.com/topic/10506-create-database/#findComment-39485
Share on other sites

[!--quoteo(post=377605:date=May 27 2006, 05:21 PM:name=avo)--][div class=\'quotetop\']QUOTE(avo @ May 27 2006, 05:21 PM) [snapback]377605[/snapback][/div][div class=\'quotemain\'][!--quotec--]
HI

If this is your server and on the same internet connection you would use something like 192.168.1.101 or localhost (no firewall or routed )(in your house)
for example

if your server is running from somewhere else in the world (one you are paying for)you would use there connection address.wwwservername.co.uk

which one is it ?

cheers.
[/quote]

the www.electric-monkey.com/ type
Link to comment
https://forums.phpfreaks.com/topic/10506-create-database/#findComment-39516
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.