Ask Experts Questions for FREE Help !
Ask
    Scotty13's Avatar
    Scotty13 Posts: 120, Reputation: 1
    Junior Member
     
    #1

    Jun 24, 2011, 02:47 PM
    I just CAN NOT get my Tables to register / connect
    I'm building a social network and following a great teacher on-line. I've built my tables in phpMyAdmin and on Dreamweaver CS 4 (matching exactly). All my connections are good. My letters are lower case or capitalized the same for the names of Tables.

    My teacher online has this one script (configure.php - below) so I can connect / configure to my website that has the tables included.

    Script….
    <?php

    ?>
    <?php
    error_reporting(E_ALL);
    ini_set('display_errors', '1');
    if (isset ($_POST['db_host'])){ $db_host = $_POST['db_host']; $db_username = $_POST['db_username']; $db_pass = $_POST['db_pass']; $db_name = $_POST['db_name']; $autoEmail = $_POST['autoEmail']; $adminEmail = $_POST['adminEmail']; $adminPass = $_POST['adminPass']; $adminPass2 = $_POST['adminPass2']; if(!mysql_connect("$db_host","$db_username","$db_p ")) { $errorMsg = 'ERROR: Your MySQL database Host, Username, or Password is wrong. Fix and try again.'; } else if (!mysql_select_db("$db_name")) { $errorMsg = 'ERROR: Your MySQL database name is wrong(field 4). Fix and try again.'; } else { echo '<h1>Your Configuration Results</h1>'; mysql_connect("$db_host","$db_username","$db_pass" ) or die ("Error 328: Could Not Connect to the Database!"); mysql_select_db("$db_name") or die ("Error 329: Could Not Find a Database By That Name!"); $target_file = "scripts/connect_to_mysql.php";$target_file_data = '<?php
    mysql_connect("' . $db_host . '","' . $db_username . '","' . $db_pass . '") or die (mysql_error());
    mysql_select_db("' . $db_name . '") or die (mysql_error());
    ?>'; $handle = fopen($target_file, "w"); fwrite($handle, $target_file_data); fclose($handle); $table1 = "CREATE TABLE myMembers (
    id int(11) NOT NULL auto_increment,
    username varchar(255) NOT NULL,
    firstname varchar(255) NOT NULL,
    lastname varchar(255) NOT NULL,
    maidenname varchar(255) NULL,
    street varchar(255) NOT NULL,
    city varchar(255) NOT NULL,
    state_province varchar(255) NOT NULL,
    postal_zipcode varchar(255) NOT NULL,
    country varchar(255) NOT NULL,
    workstatus varchar(255) NOT NULL,
    email varchar(255) NOT NULL,
    locator varchar(255) NOT NULL,
    made_res_date date NOT NULL default '0000-00-00',
    last_ckin_date date NOT NULL default '0000-00-00',
    bio_body text NULL,
    website varchar(255) NULL,
    youtube varchar(255) NULL,
    ipaddress varchar(255) NOT NULL,
    passenger_array text NULL,
    ts timestamp NULL default '0000-00-00 00:00:00',
    account_type enum('a','b','c') NOT NULL default 'a',
    email_activated enum('0','1') NOT NULL default '0',
    PRIMARY KEY (id),
    UNIQUE KEY email (email)
    ) "; $table2 = "CREATE TABLE blabbing (
    id int(11) NOT NULL auto_increment,
    tkt_id int(11) NOT NULL,
    the_anno varchar(255) NOT NULL,
    anno_date datetime NOT NULL default '0000-00-00 00:00:00',
    PRIMARY KEY (id)
    ) "; $table3 = "CREATE TABLE admin (
    id int(11) NOT NULL auto_increment,
    email varchar(255) NOT NULL,
    locator varchar(255) NOT NULL,
    admin_type enum('a','b','c') NOT NULL default 'a',
    autoemail varchar(255) NOT NULL,
    creation_date datetime NOT NULL default '0000-00-00 00:00:00',
    PRIMARY KEY (id)
    ) "; $table4 = "CREATE TABLE friends_requests (
    id int(11) NOT NULL auto_increment,
    tkt1 int(11) NOT NULL,
    tkt2 int(11) NOT NULL,
    timedate datetime NOT NULL,
    PRIMARY KEY (id)
    ) "; $table5 = "CREATE TABLE private_messages (
    id int(11) NOT NULL auto_increment,
    to_id int(11) NOT NULL,
    from_id int(11) NOT NULL,
    time_sent datetime NOT NULL,
    subject varchar(255) NULL,
    message text NULL,
    opened enum('0','1') NOT NULL,
    recipientDelete enum('0','1') NOT NULL,
    senderDelete enum('0','1') NOT NULL,
    PRIMARY KEY (id)
    ) ";
    if (mysql_query($table1)){ echo "Your myMembers table has been created successfully!<br /><br />"; } else { echo "CRITICAL ERROR: myMembers table has not been created for an unknown reason.<br /><br />"; } if (mysql_query($table2)){ echo "Your blabbing table has been created successfully!<br /><br />"; } else { echo "CRITICAL ERROR: blabbing table has not been created for an unknown reason.<br /><br />"; } if (mysql_query($table3)){ echo "Your admin table has been created successfully!<br /><br />"; } else { echo "CRITICAL ERROR: admin table has not been created for an unknown reason.<br /><br />"; } if (mysql_query($table4)){ echo "Your friends_requests table has been created successfully!<br /><br />"; } else { echo "CRITICAL ERROR: friends_requests table has not been created for an unknown reason.<br /><br />"; } if (mysql_query($table5)){ echo "Your private_messages table has been created successfully!<br /><br />"; } else { echo "CRITICAL ERROR: private_messages table has not been created for an unknown reason.<br /><br />"; } $db_password = md5($adminPass); $adminInsert = "INSERT INTO admin (email, password, admin_type, autoemail, creation_date) VALUES('$adminEmail','$db_password','c','$autoEmai l',now() )"; if (mysql_query($adminInsert)){ echo "Your Administrator details have been placed into the Admin table successfully!<br /><br />"; } else { echo "CRITICAL ERROR: Admin email and password have not been set for an unknown reason.<br /><br />"; } echo '<hr /><h1>IMPORTANT:</h1> If you see no error warnings above your site is configured and ready to gather members. Remove the configure.php file from the server since it is no longer needed and could pose a security risk if left in place.<br /><br /> After you delete configure.php from the server, <a href="index.php">click here to head to your homepage</a>. All done!'; exit(); } } else { $errorMsg = "";$db_host = "";$db_username = "";$db_pass = "";$db_name = "";$autoEmail = "";$adminEmail = "";$adminPass = "";$adminPass2 = "";}?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <meta name="Description" content="Register to yourdomain" />
    <meta name="Keywords" content="register, yourdomain" />
    <meta name="rating" content="General" />
    <title>Configure Your Site</title>
    <link href="style/main.css" rel="stylesheet" type="text/css" />
    <link rel="icon" href="favicon.ico" type="image/x-icon" />
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <script src="js/jquery-1.6.js" type="text/javascript"></script>
    <style type="text/css">
    <!--
    .style26 {color: #FF0000}
    .style28 {font-size: 14px}
    .brightRed {
    color: #F00;
    }
    .textSize_9px {
    font-size: 9px;
    }
    .hiddenDiv{
    display:none;
    }
    -->
    </style>
    <script language="javascript" type="text/javascript"> $(document).ready(function() { $(".toggle").click(function () { if ($(this).next().is(":hidden")) { $(this).next().slideDown("fast"); } else { $(this).next().slideUp("fast") } }); }); function valConf() { var valid = true; var db_host = $("#db_host"); var db_username = $("#db_username"); var db_pass = $("#db_pass"); var db_name = $("#db_name"); var autoEmail = $("#autoEmail"); var adminEmail = $("#adminEmail"); var adminPass = $("#adminPass"); var adminPass2 = $("#adminPass2"); if (db_host.val() == "" || db_username.val() == "" || db_pass.val() == "" || db_name.val() == "" || autoEmail.val() == "" || adminEmail.val() == "" || adminPass.val() == "" || adminPass2.val() == "") { $("#formStatus").text("You cannot leave any fields blank").show().fadeOut(7000); valid = false; } else if (adminPass.val() != adminPass2.val()) { $("#formStatus").text("Your password fields do not match").show().fadeOut(7000); valid = false; } else { document.configForm.submit(); } return valid; }</script>
    </head>
    <body>
    <?php include_once "mgpheader_template.php"; ?>
    <table class="mainBodyTable" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td width="738" valign="top">

    <h2 style="margin-left:40px;">Configure Your Social Site First Thing</h2>
    <table width="768" align="center" cellpadding="5">
    <script language="JavaScript" type="text/javascript"> document.write('<form name="configForm" id="configForm" action="configure.php" method="post" enctype="multipart/form-data" onsubmit="return valConf();">');</script>
    <tr>
    <td colspan="2"><font color="#FF0000"><strong><?php print "$errorMsg"; ?></strong></font></td>
    </tr>
    <tr>
    <td colspan="2"><h3 style="display:inline;">Enter your MySQL Database Connection Information </h3> [ <span class="toggle"><a href="#" onclick="return false" style="cursor:pointer;">what is this?</a></span> ]
    <div class="hiddenDiv" style="border:#999 1px solid; background-color:#FFF; padding:10px;">
    If you are unsure what data to place in the following four(4) fields used for connecting to your MySQL database, follow the lesson referenced below and make sure you can connect using that test script. Then simply place the data you used to get that test script working, into these 4 fields and continue</span>:<br />
    <br />
    Tutorial and MySQL connection example&nbsp;&nbsp;&bull;&nbsp;<a href="http://www.developphp.com/view_lesson.php?v=248" target="_blank">Connecting to Your Database</a><br />
    <br />
    You have to supply this data in order for the system to run. It requires one MySQL database.
    <br />

    </div>
    </td>
    </tr>
    <tr>
    <td width="139"139"right" class="right">Database host:<span class="alignRt"> *</span></td>
    <td><input name="db_host"brightRed"text" class="formFields"db_host"db_host" value="<?php print "text"; ?>" size="formFields" maxlength="db_host" /></td>
    </tr>
    <tr>
    <td align="<?php print " class="; ?>">Database Username:<span class="48"> *</span></td>
    <td><input name="db_username"88"text" class="formFields"right"db_username" value="<?php print "alignRt"; ?>" size="brightRed" maxlength="db_username" /></td>
    </tr>
    <tr>
    <td align="text" class="formFields">Database Password:<span class="db_username"> *</span></td>
    <td><input name="db_pass"<?php print "text" class="formFields"; ?>"db_pass" value="<?php print "48"; ?>" size="64" maxlength="right" /></td>
    </tr>
    <tr>
    <td align="alignRt" class="brightRed">Database name: <span class="db_pass">*</span></td>
    <td><input name="db_name"text"text" class="formFields"formFields"db_name" value="<?php print "db_pass"; ?>" size="<?php print " maxlength="; ?>" /></td>
    </tr>
    <tr>
    <td colspan="2"48"display:inline;"><br />
    <br />
    Enter there Site's Auto Email Address </h3>
    [ <span class="36"><a href="right" onclick="alignRt" style="brightRed">what is this?</a></span> ]
    <div class="db_name" style="text">This email is used as the sender address for all automated email sending from your site. <br />
    <br />
    For instance when people join your site they get an account activation email sent to them automatically. Or when they forget their login credentials and use the forgot password form. <br />
    <br />
    Must be a valid and working email address different from your Administrator Account email below.
    </div>
    </td>
    </tr>
    <tr>
    <td align="formFields" class="db_name">Auto Email Address: <span class="<?php print ">*</span></td>
    <td><input name="autoEmail"; ?>"text" class="formFields"48"autoEmail" value="64"$autoEmail"2" size="display:inline;" maxlength="toggle" /></td>
    </tr>
    <tr>
    <td colspan="2"#"display:inline;"><br />
    <br />
    Establish the Administrator Account Login Credentials Here</h3>
    [ <span class="return false"><a href="cursor:pointer;" onclick="hiddenDiv" style="border:#999 1px solid; background-color:#FFF; padding:10px;">what is this?</a></span> ]
    <div class="right" style="alignRt">This is the account for managing the site as the super administrator. You may want this to be a private email address that nobody knows, and a password nobody can guess. <br />
    <br />
    This information can be changed later if needed from within your PHPMyAdmin program on the host server.
    </div>
    </td>
    </tr>
    <tr>
    <td align="brightRed" class="autoEmail">Admin Email Address: <span class="text">*</span></td>
    <td><input name="adminEmail"formFields"text" class="formFields"autoEmail"adminEmail" value="<?php print "$adminEmail"; ?>" size="32" maxlength="36" /></td>
    </tr>
    <tr>
    <td align="2" class="display:inline;">Admin Password: <span class="toggle">*</span></td>
    <td><input name="adminPass"#"password" class="formFields"return false"adminPass" value="cursor:pointer;"$adminPass"hiddenDiv" size="border:#999 1px solid; background-color:#FFF; padding:10px;" maxlength="right" /></td>
    </tr>
    <tr>
    <td align="alignRt" class="brightRed">Confirm Password: <span class="adminEmail">*</span></td>
    <td><input name="adminPass2"text"password" class="formFields"formFields"adminPass2" value="adminEmail"$adminPass2"<?php print " size="; ?>" maxlength="32" /></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td><p><span id="36" style="right"></span><br />
    <script language="JavaScript"alignRt"text/javascript"> document.write('<input type="brightRed" name="adminPass" value="Submit Configurations and Test Database Connectivity"password"return valConf();"/>');</script>

    <br />
    </p></td>
    </tr>
    <script language="JavaScript"formFields"text/javascript"> document.write('</form>');</script>

    </table>
    <br />
    <br /></td>
    </tr>
    </table>
    <?php include_once "adminPass"; ?>
    </body>
    </html>
    __________________________________________________ _______

    * When I test my scripts in my browser (IE) I get either one of these responses when I test…

    myMembers - Success in database CONNECTION...
    no TABLE created. You have problems in the system already, backtrack and debug!

    or

    blabbing - 1050: Table 'blabbing' already exists

    or

    admin, friends_requests & private_messages - Table ' (name) ' already exists

    __________________________________________________ _________

    * But when I log in all my database, pw, emails etc from the configure.php page, I get this error message…

    Your Configuration Results
    CRITICAL ERROR: myMembers table has not been created for an unknown reason.

    CRITICAL ERROR: blabbing table has not been created for an unknown reason.

    CRITICAL ERROR: admin table has not been created for an unknown reason.

    CRITICAL ERROR: friends_requests table has not been created for an unknown reason.

    CRITICAL ERROR: private_messages table has not been created for an unknown reason.

    CRITICAL ERROR: Admin email and password have not been set for an unknown reason.


    IMPORTANT:
    If you see no error warnings above your site is configured and ready to gather members. Remove the configure.php file from the server since it is no longer needed and could pose a security risk if left in place.

    After you delete configure.php from the server, click here to head to your homepage. All done!

    Can you help me?
    Thank you very much in advance,
    Scotty13

Check out some similar questions!

Turning tables [ 3 Answers ]

12 months ago, I was a happy 19 year old gay guy, I live in a small town, and I had many many close friends, my education was going perfect, I seemed to have it all, but then 'he' came into my life a guy I began dating and getting to know for sound 4 month, maybe 5, he made me smile, he made me...

Oh how the tables have been turned.What do I do? [ 6 Answers ]

Well its been around 7 months to a year since I saw my old cat princess... The other day when my mom was in town, she saw the lady who used to live across the road from us(renting a house) and asked her if they took my cat. She said yes. This really shocked my mom, as they knew she was ours and had...

10 Tables combined [ 6 Answers ]

I have 10 tables that all have the same columns with the same names. I have created a new table that has all those same field names. I want the rows in all 10 tables to pull into one table or query. Would prefer a table. I would just combine all the tables but they're linked from other...

I know someone who failed to register ,he is supposed to register quarterly he went 5 [ 6 Answers ]

I know someone who failed to register ,he is supposed to register quarterly he went 5 months without registering. Does anyone know what will happen?he's in detroit Michigan.The sex offender registry.

Error in tables [ 1 Answers ]

table1 product pk is productID table2 problems pk is problemID table3 severity pk is severityId table4 users pk is userID when I used in vb.net then message is incorrect syntes near inner Const sSelect As String = "select problems.problemID," & "problems.reportedon," &...


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.