Jump to content

tjhilder

Members
  • Posts

    136
  • Joined

  • Last visited

    Never

Everything posted by tjhilder

  1. thanks very much, sometimes seems to take someone elses point of view to figure out the error and correct it.
  2. I've been fiddling around with some code but it doesn't seem to work right, I been trying several things but to no success, anyone able to help me on this one? <?php $username = $_POST['username']; $password = $_POST['password']; $fullname = $_POST['full_name']; $email = $_POST['email']; $url = $_SERVER['PHP_SELF']; ini_set('display_errors',1); error_reporting(E_ALL & ~E_NOTICE); if (isset ($_POST['submit'])) { DEFINE (DB_USER, "username"); DEFINE (DB_PASSWORD, "password"); DEFINE (DB_HOST, "localhost"); DEFINE (DB_NAME, "database"); if ($dbc = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD)) { if (@mysql_select_db(DB_NAME)) { die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>'); } } else { die ('<p>Could not connect to MySQL because: <b>' . mysql_error() . '</b></p>'); } $query = "INSERT INTO members (member_userid, member_username, member_password, member_fullname, member_email, member_rank) VALUES ( 0, '$username', '$password', '$fullname', '$email', '3' )"; if (@mysql_query($query)) { print '<p>The blog entry has been added.</p>'; } else { print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>"; } } mysql_close(); ?> <form action="<? echo $url ?>" method="post"> <input type="text" name="full_name" cols="60" /><br /> <input type="text" name="username" cols="60" /><br /> <input type="text" name="password" cols="60" /><br /> <input type="text" name="email" cols="60" /><br /> <input type="submit" name="submit" value="Add Member!" /><br /> everytime i enter information it brings up the database error but nothing appears with mysql_error(), this is what I get: Could not select the database because: if I knew what the error was maybe I'd know what I'm meant to be doing but it doesn't seem to want to show up. any suggestions?
  3. thanks, I believe that worked, but I'm not sure. how do I check it? I don't know how to display the information, can anyone help me please?
  4. Hi, I'm new to MySQL and know a limited knowledge of PHP, so I'm having a problem with trying to put information into MySQL, can someone tell me what I'm doing wrong with this code? <?php $uid = 'member_userid'; $uname = 'member_username'; $pwd = 'member_password'; $fname = 'member_fullname'; $email = 'member_email'; $rank = 'member_rank'; // get connection and database information require_once('admin/mysql/mysql_connect.inc'); // Insert information into members for member: tjhilder $query = "INSERT INTO members ($uid,$uname,$pwd,$fname,$email,$rank) VALUES ( `1`, `tjhilder`, `something`, `TJ Hilder`, `tjhilder@something.com`, `1` )"; // Create data for Members mysql_query($query) or die(mysql_error()); echo "<a href=\"mysql3.php\">Click Here</a>"; ?> I'm getting this error: Unknown column '1' in 'field list' thanks in advance if you can help me TJ
  5. Ok I figured out what was wrong, was too many mysql_query() in the script.
  6. Ok so I changed the code, dunno if this is right, i took out the 2nd "AUTO_INCREMENT" and added the die() part, and now it looks like this: <?php // get connection and database information require_once('admin/mysql/mysql_connect.inc'); // Create information for Members $query = mysql_query("CREATE TABLE members ( `member_userid` INT(11) NOT NULL AUTO_INCREMENT, `member_username` VARCHAR(25) NOT NULL, `member_password` VARCHAR(100) NOT NULL, `member_fullname` VARCHAR(60) NOT NULL, `member_email` VARCHAR(60) NOT NULL, `member_rank` INT(11) NOT NULL, PRIMARY KEY (member_userid) "); // Create Table for Members mysql_query($query) or die(mysql_error()); ?> and the error returned was: Query was empty solution? I figure I better mention that I found some code that lists the tables in your database, and it lists no databases. which i have on another php file.
  7. I been trying to put this code into practice, but it doesn't seem to want to create the table, I do have the privliges to do so, any ideas on what I'm doing wrong? <?php // get connection and database information require_once('admin/mysql/mysql_connect.inc'); // Create information for Members $query2 = mysql_query("CREATE TABLE members ( `member_userid` INT(11) NOT NULL AUTO_INCREMENT, `member_username` VARCHAR(25) NOT NULL, `member_password` VARCHAR(25) NOT NULL, `member_fullname` VARCHAR(60) NOT NULL, `member_email` VARCHAR(60) NOT NULL, `member_rank` INT(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (member_userid) "); // Create Table for Members mysql_query($query2); ?>
  8. thanks that did work I have a few more questions, how would I.. 1. add more then one column when creating a table? 2. delete a column? 3. edit a column? 4. add data to those colums? TJ
  9. for the last 30 - 45 minutes I've been trying to create a table in my database (using my brother's home server) but I can't seem to get it to work. trying to get this to work: [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]$query = \"CREATE TABLE members (username VARCHAR(25) NOT NULL)\"; mysql_db_query($query);[/span][!--PHP-Foot--][/div][!--PHP-EFoot--] I have all the correct connection code and database select code but it seems to be this thats giving me the headache. maybe someone could point me in the right direction with this.
  10. Hi, I'm trying to connect to MySQL but I get this error. apparently it's cos MySQL isn't operating, how would I start it on FreeBSD 5.3?
×
×
  • 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.