Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    New to the CF scene
    Join Date
    Jan 2004
    Location
    San Diego
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb need help troubleshooting php error

    Hello,

    I have a script that is supposed to create tables for me. For some reason I keep getting an error that says "could not create bm_data table". I am not sure where to look to correct this error, whether it is in the makedatafiles.php file or the variables file. Here is the makedatafiles.php code, if anyone could help me identify the error it would be greatly appreciated:

    <?

    include('./variables.php');
    /*
    $result = "CREATE TABLE bm_data (id INT(11) default NULL auto_increment, address char(50) default NULL, PRIMARY KEY (id)) TYPE=MyISAM";

    mysql_query($result,$GLOBALS['link'])
    or die ("<br>Could not create Table 'bm_data' ");
    */
    //$result = "CREATE TABLE bm_remove (id INT(11) default NULL auto_increment, address char(50) default NULL, PRIMARY KEY (id)) TYPE=MyISAM";

    //mysql_query($result,$GLOBALS['link'])
    //or die ("<br>Could not create Table 'bm_remove' ");
    /*
    $result = "CREATE TABLE bm_stats (num_of_addresses INT(12) default NULL, last_sent char(20) default NULL) TYPE=MyISAM";

    mysql_query($result,$GLOBALS['link'])
    or die ("<br>Could not create Table bm_stats");

    $result = "INSERT INTO bm_stats VALUES(NULL,0,'Never!')";

    mysql_query($result,$GLOBALS['link'])
    or die ("<br>Could not open Table bm_stats");


    print "<BR>";
    print "If no errors have been reported, success!";*/
    ?>

  • #2
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    1) Are you connected to the database?
    2) Have you selected the correct database?

  • #3
    New to the CF scene
    Join Date
    Jan 2004
    Location
    San Diego
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, I am connected to the database, as far as selecting the correct database yes, I have the database name, username, and password correct as far as I know.

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    MySQL provides you with an error message if a query fails. You can print it out like this:

    PHP Code:
    mysql_query($result,$GLOBALS['link'])
    or die (
    "<br>Could not create Table 'bm_data' " mysql_error()); 
    De gustibus non est disputandum.

  • #5
    New to the CF scene
    Join Date
    Jan 2004
    Location
    San Diego
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I do not have full access to the server except load and upload files. When I type in the path to the domain .../makedatafiles.php the only thing that comes up is a blank page with "Could not create Table 'bm_data' " written on it

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't understand. You say you have the rights to upload files, so did you edit the makedatafiles.php file and upload it to your server? And if you did so, did I understand you correctly that the error message of MySQL is really empty, and the code returned the same output as before? I'm confused.

    Have you checked that your script has permissions to create tables in the database? Does it work if you create a table inside phpMyAdmin, logging in with the same authentication data as your script?
    De gustibus non est disputandum.

  • #7
    New to the CF scene
    Join Date
    Jan 2004
    Location
    San Diego
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Forgive me, I do not mean to be confusing. I am not fully versed in PHP. I have a programmer, who works on a part time basis for me. He wrote the script. However, it was supposed to be done yesterday for a very, very important project. It was not done. Now I am doing what I can to try and troubleshoot this issue. In regards to your statements

    I have not edited the makedatafiles.php, I am trying to figure out if this is the file I am supposed to be editing as opposed to the variables.php file.

    In regards to this: QUOTE] Have you checked that your script has permissions to create tables in the database? Does it work if you create a table inside phpMyAdmin, logging in with the same authentication data as your script?[/QUOTE]

    I would have that that the databse name, username, and password would have been the permissions. I am afraid my technical background in PHP is too limited in order to be able to give you the correct info for my problem. I appreciate you trying to help though.

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by fisher318
    I have a programmer, who works on a part time basis for me. He wrote the script. However, it was supposed to be done yesterday for a very, very important project. It was not done.
    May I conclude from this that you already tried to contact your programmer to fix this issue? Hmh, obviously, or you wouldn't post here...

    Now I am doing what I can to try and troubleshoot this issue.
    Ok. In this case you will have to provide us as much info as you can give so we can help you.

    I have not edited the makedatafiles.php, I am trying to figure out if this is the file I am supposed to be editing as opposed to the variables.php file.
    You need to edit the makedatafiles.php with the code I posted so we can make sure what kind of error the script has. The posted code does only contain a diagnostic routine that prints out an error message. It won't interfer with the rest of your code, honestly. But the error message is really important because without it, all we can do is make educated guesses.

    The SQL query used in the code is alright, I tested it on my system.

    I would have that that the databse name, username, and password would have been the permissions. I am afraid my technical background in PHP is too limited in order to be able to give you the correct info for my problem.
    You connect to the MySQL server as a user with certain rights. It could be that your authentication data (username, password) allows you only to read the database, but not to create anything in it. Maybe your programmer wrote the script and tested it only on his local system. If that's the case, you need the administrator of the MySQL server to extend the rights of your user account.

    Do you know what phpMyAdmin is? If yes, can you log in and are you able to create tables from it?

    Another oddity that I found is that almost everything in the code snippet you posted is commented out. The code above should not have printed out anything. Is the code above in the same state as you got it from your programmer?
    De gustibus non est disputandum.

  • #9
    New to the CF scene
    Join Date
    Jan 2004
    Location
    San Diego
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok, I inserted the code you gave me and re-uploaded the makedatafiles.php and then ran it. I still got a blank page.

    This leads me to believe that maybe you are right about the read only privilages.

    I am unfamiliar with phpMyAdmin. Sorry.

    And yes, the code is still in tact from when my programmer gave it to me. The odd thing is that this program runs perfectly fine on a different web site on my main server, but we took the exact same code and added it to this other hosting server which is not mine, changed the passwords as needed, and now it is not working.

    Is there a way we can check to see if we have read only rights or creating rights?
    Last edited by fisher318; 01-21-2004 at 10:23 PM.

  • #10
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok, I inserted the code you gave me and re-uploaded the makedatafiles.php and then ran it. I still got a blank page.
    Wait - you said in your first post that you got an error message. And now the whole page is blank?

    And yes, the code is still in tact from when my programmer gave it to me.
    Very strange... this code shouldn't have printed anything in the first case. What is the content of variables.php? Can you post it after removing any confidential connection data?

    It looks as if this code was a script to create the needed tables at the start of your application, and was commented out (read: disabled) after that.

    Is there a way we can check to see if we have read only rights or creating rights?
    Indirectly, yes. Run this code - it will attempt to create a test table and remove it immediately. If all runs ok, the message at the bottom will be displayed. You have put your connection data into the first two functions:

    PHP Code:
    $conn mysql_connect('server''username''password') or die(mysql_error());
    $db   mysql_select_db('databasename') or die(mysql_error());;

    $query "CREATE TABLE bm_test(id INT(11) default NULL) TYPE=MyISAM";

    mysql_query($query)
    or die (
    "<br>Could not create Table 'bm_test' because: " mysql_error());

    $query "DROP TABLE bm_test";

    mysql_query($query)
    or die (
    "<br>Could not drop Table 'bm_test' because: " mysql_error());

    print 
    'you have rights to create/drop tables'
    De gustibus non est disputandum.

  • #11
    New to the CF scene
    Join Date
    Jan 2004
    Location
    San Diego
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes the whole page is blank now. It has done this before.


    ok, here is the variables code:

    <?php

    //DB USE

    $user = "username";
    $password = "password";
    $db = "dbname";
    $server = "localhost";

    //This is for global database connectivity
    global $link;
    $link = mysql_connect ($server, $user, $password);
    if (! $link)
    {
    die ("Couldn't connect to mySQL server");
    }
    if (!mysql_select_db ($db, $link) )
    {
    die ("Couldn't open $db: ".mysql_error() );
    }

    //********
    //these are for the login to the bulk mail
    //********
    global $user;
    global $pass;

    $user = "user";
    $pass = "pass";

    //*********
    //this is for the bulk email sender
    //*********
    global $emailfrom;
    global $fullname;
    global $subject;

    $emailfrom = "from";
    $fullname = "Jeremy Morris";
    $subject = "Newsletter";






    ?>

    What about that script you sent over? Do I integrate that into one of my current pages, or create a new page for it and then upload and run it?

  • #12
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The variables.php looks ok, shouldn't interfer with the code in makedatafiles.php. It just establishes a connection and defines some global variables. Hmh. Judging from the code I know until now, I'd say if no error messages appear, the whole thingie should work?

    Can you check if the tables have been actually created by running this script in a separate file, with an arbitrary name?

    PHP Code:
    $conn mysql_connect('server''username''password') or die(mysql_error());
    $db   mysql_select_db('databasename') or die(mysql_error());;

    $query "SELECT count(*) FROM bm_data";
    $result mysql_query($query) or die ("<br>error in query: " mysql_error());

    if (
    $result) {
    print 
    mysql_num_rows($result);
    while (
    $row mysql_fetch_array($result)) {
    var_dump($row);
    }
    } else {
    print 
    'error in query';

    De gustibus non est disputandum.

  • #13
    New to the CF scene
    Join Date
    Jan 2004
    Location
    San Diego
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok, I also just checked and I do have rights to create and/or drop tables


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •