Jump to content

Heres a DUMB Question...


BradD

Recommended Posts

Moaning:

 

This may seem like a dumb question, but I can't get a form to communicate with the database, So my question is:

 

If my database is unclebob_unclebobrocks and the table is called members and the Generate php code tab in the database gives:

 $sql = "SELECT * FROM `members` LIMIT 0, 30 ";

 

Do I need to add this value to:

$sql_username_check = mysql_query("SELECT * id FROM `members` WHERE username='$username' LIMIT 1");

 

Or should it be more like:

$sql_username_check = mysql_query("SELECT * id FROM unclebob_unclebobrocks_members WHERE username='$username' LIMIT 1");

 

 

"also need to turn on error reporting but  :wtf: who would have thought that would be such a difficult task? "Is it just me or is this php.ini file really hard to gain access to?

 

the phpinfo.php file tells me the file path to the php.ini file is /usr/lib That's Great, but I still can't figure out how to get there??? I have tried every combination of url I can thing of?

 

It's not loaded on my computer and I can't for the life of me figure out how to access the php.ini file through the PHP Configuration mode in cpanel.

What piece of the puzzle am I missing here?

 

Any help greatly appreciated.

 

 

 

Link to comment
Share on other sites

To turn error reporting on:

 

error_reporting(E_ALL);

 

At the top of your script. Now, for the sql query question, this is correct:

 

$sql_username_check = mysql_query("SELECT * id FROM `members` WHERE username='$username' LIMIT 1");

 

However, you need to make sure you connect to the database first:

 

<?php

//connect to database
    $host = 'localhost';
    $user = 'root';
    $pass = '';

    // open connection
    $connection = mysql_connect($host, $user, $pass) or die('Unable to connect!');
    mysql_select_db('unclebob_unclebobrocks');
?> 

Link to comment
Share on other sites

Thanks kratsg:

I am definitely connected to the database through the require_once('connect.php'); which I have tested with a mysqltest file using a connection echo, so I know that bit is OK.

 

There is also an $errorMSG =" " That should display in the form  <td colspan="2"><font color="#FF0000"><?php echo "$errorMsg"; ?></font></td> if certain fields have not been filled, but no message will display and no data is making it to the database.

 

Surely the problem lies in

$sql_username_check = mysql_query("SELECT * id FROM `members` WHERE username='$username' LIMIT 1");

and something I am not getting right?

 

To turn error reporting on:

 

error_reporting(E_ALL);

 

At the top of your script. Now, for the sql query question, this is correct:

 

[code=php:0]$sql_username_check = mysql_query("SELECT * id FROM `members` WHERE username='$username' LIMIT 1");

[/code]

 

However, you need to make sure you connect to the database first:

 

<?php

//connect to database
    $host = 'localhost';
    $user = 'root';
    $pass = '';

    // open connection
    $connection = mysql_connect($host, $user, $pass) or die('Unable to connect!');
    mysql_select_db('unclebob_unclebobrocks');
?> 

Link to comment
Share on other sites

So the question is:

 

Are you trying to add data to the database?

- Use an "INSERT" query.

Are you trying to update data in the database?

- Use an "UPDATE" query.

Are you trying to retrieve data from the database?

- Use a "SELECT" query.

Link to comment
Share on other sites

So the question is:

 

Are you trying to add data to the database?

- Use an "INSERT" query.

Are you trying to update data in the database?

- Use an "UPDATE" query.

Are you trying to retrieve data from the database?

- Use a "SELECT" query.

 

I'm using INSERT and SELECT and it's still not behaving the way it should, what am I missing here? Can you see any problems with the script?

 

 

<?php
error_reporting(E_ALL);

// Set error message as upon arrival to page
$errorMsg = "";
// First we check to see if the form has previously been submitted 
if (isset($_POST['username'])){
//Connect to DB
require_once('connectDB.php');
// Filter the posted variables
$first = ereg_replace("[^A-Za-z0-9]", "", $_POST['firstnam']); // up arrow filters everything but letters and numbers without up arrow will filter all letters and numbers
$last = ereg_replace("[^A-Za-z0-9]", "", $_POST['lastname']); // ^ filters everything but letters and numbers
$UserName = ereg_replace("[^A-Za-z0-9]", "", $_POST['username']); // ^ filters everything but numbers and letters
$password = ereg_replace("[^A-Za-z0-9]", "", $_POST['password']); // filter everything but numbers and letters
$country = ereg_replace("[^A-Z a-z0-9]", "", $_POST['country']); // filter everything but spaces, numbers, and letters
$state = ereg_replace("[^A-Z a-z0-9]", "", $_POST['state']); // filter everything but spaces, numbers, and letters
$city = ereg_replace("[^A-Z a-z0-9]", "", $_POST['city']); // filter everything but spaces, numbers, and letters there is a space here allowing spaces
$phone = ereg_replace("[^A-Za-z0-9]", "", $_POST['phone']); // not sure what to filter will have to experiment 
$mobile = ereg_replace("[^A-Za-z0-9]", "", $_POST['mobile']);
$business = ereg_replace("[^A-Za-z0-9]", "", $_POST['business']);
$email = stripslashes($_POST['email']);
$email = strip_tags($email);
$email = mysql_real_escape_string($email);
$website = ereg_replace("[^A-Za-z0-9]", "", $_POST['website']); // also not sure what to filter will need to test 
// Check to see if the user filled all fields with
// the "Required"(*) symbol next to them in the join form
// and print out to them what they have forgotten to put in
if((!$firstname) || (!$lastname) || (!$username)  || (!$password) || (!$email) || (!$accounttype) || (!$country) || (!$state) || (!$city) ){

	$errorMsg = "You did not submit the following required information!<br /><br />";
	if(!$firstname){
		$errorMsg .= "--- First Name";
	} else if(!$lastname){
		$errorMsg .= "--- Last Name";
    } else if(!$Username){
		$errorMsg .= "--- UserName";
	} else if(!$password){
		$errorMsg .= "--- Password";
	} else if(!$country){
		$errorMsg .= "--- Email"; 
	} else if(!$state){ 
	    $errorMsg .= "--- Account Type"; 
    } else if(!$city){ 
        $errorMsg .= "--- Country"; 
	} else if(!$accounttype){
		$errorMsg .= "--- State"; 
    } else if(!$email){ 
       $errorMsg .= "--- City"; 
} else {
// Database duplicate Fields Check
$sql_username_check = mysql_query("SELECT * id FROM `members` WHERE username='$username' LIMIT 1"); // DB is not primary_database but path is same_structure
$sql_email_check = mysql_query("SELECT * id FROM `members` WHERE email='$email' LIMIT 1");
$username_check = mysql_num_rows($sql_username_check);
$email_check = mysql_num_rows($sql_email_check); 
if ($username_check > 0){ 
	$errorMsg = "<u>ERROR:</u><br />Your User Name is already in use inside our system. Please try another.";
} else if ($email_check > 0){ 
	$errorMsg = "<u>ERROR:</u><br />Your Email address is already in use inside our system. Please try another.";
} else {
	// Add MD5 Hash to the password variable
       $hashedPass = md5($password); 
	// Add user info into the database table, claim your fields then values 
	$sql = mysql_query("INSERT * INTO `members` (firstname, lastname, username, password, country, state, city, accounttype, emailactivated, signupdate, phone, mobile, business, email, website, signupdate, emailactivated, lastlogin) 
	                    VALUES('$firstname','$lastname','$username','$password','$email','$accounttype','$country','$state','$city','$phone','$mobile','$business','$hashedPass','$website',        'signupdate','emailactivated','lastlogin', now())") or die (mysql_error());
	// Get the inserted ID here to use in the activation email, 
	$id = mysql_insert_id();
	// Create directory(folder) to hold each user files(pics, MP3s, etc.) 
	mkdir("memberFiles/$id", 0755); 
	// Start assembly of Email Member the activation link
	$to = "$email";
	// Change this to your site admin email
	$from = "brad@mlmnetworkingsystem.com";

	$subject = "Complete your registration";
	//Begin HTML Email Message where you need to change the activation URL inside
	$message = '<html>
	<body bgcolor="#FFFFFF">
	Hi ' . $username . ',
	<br /><br />
	Confirm your registration.
	<br /><br />
	Please click here to activate now >>
	<a href="http://www.mlmnetworkingsystem.com/activation.php?id=' . $id . '">
	ACTIVATE NOW</a>
	<br /><br />
	Your Login Data is as follows: 
	<br /><br />
	E-mail Address: ' . $email . ' <br />
	Password: ' . $password . ' 
	<br /><br /> 
	Thanks! 
	</body>
	</html>';
	// end of message
	$headers = "From: $from\r\n"; // \r opens database read only and \n creates new database truncate old versions if they exist
	$headers .= "Content-type: text/html\r\n";
	$to = "$to";
	// Finally send the activation email to the member
	mail($to, $subject, $message, $headers);
	// Then print a message to the browser for the joiner 
	print "<br /><br /><br /><h4>OK $firstname, one last step to verify your email identity:</h4><br />
	We just sent an Activation link to: $email<br /><br />
	<strong><font color=\"#990000\">Please check your email inbox in a moment</font></strong> to click on the Activation <br />
	Link inside the message. After email activation you can log in.";
	exit(); // Exit so the form and page does not display, just this success message
} // Close else after database duplicate field value checks
  } // Close else after missing vars check
} //Close if $_POST
}
?>

<!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=utf-8" />
<title>Registration</title>
</head>
<body>
  <table width="528" align="center" cellpadding= "4">
  <tr>
  <td width= = "7%">REGISTER AS A MEMBER BELOW </td>
  </tr>
  </table>
  <table width= "528" align= "center" cellpadding= "5">
    <form action="jointoday.php" method="post" enctype="multipart/form-data">
     <tr>
      <td colspan="2"><font color="#FF0000"><?php echo "$errorMsg"; ?></font></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">First Name:</td>
      <td><input name="first" type="text" value="<?php echo "$firstname"; ?>" size="40" maxlength="40" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Last Name:</td>
      <td><input name="last" type="text" value="<?php echo "$lastname"; ?>" size="40" maxlength="40" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Username:</td>
      <td><input name="Username" type="text" value="<?php echo "$username"; ?>" size="40" maxlength="40" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Password:</td>
      <td><input name="password" type="text" value="<?php echo "$password"; ?>" size="32" maxlength="32" /></td>
    </tr>
     <tr valign="baseline">
      <td align="right">Account Type:</td>
      <td><select name="accounttype">
        <option value="<?php echo "$accounttype"; ?>"><?php echo "$accounttype"; ?></option>
        <option value="a">Normal User</option>
        <option value="b">Expert User</option>
        <option value="c">Super User</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Country:</td>
      <td>
        <select name="Country" size="1" id="Country" >
<option value="<?php echo "$country"; ?>"><?php echo "$country"; ?></option>        
<option value="AA" selected>(please select a country)</option>
<option value="AA">none</option>
<option value="AF">Afghanistan</option>
<option value="AL">Albania</option>
<option value="DZ">Algeria</option>
<option value="AS">American Samoa</option>
<option value="AD">Andorra</option>
<option value="AO">Angola</option>
<option value="AI">Anguilla</option>
<option value="AQ">Antarctica</option>
<option value="AG">Antigua and Barbuda</option>
<option value="AR">Argentina</option>
<option value="AM">Armenia</option>
<option value="AW">Aruba</option>
<option value="AU">Australia</option>
<option value="AT">Austria</option>
<option value="AZ">Azerbaijan</option>
<option value="BS">Bahamas</option>
<option value="BH">Bahrain</option>
<option value="BD">Bangladesh</option>
<option value="BB">Barbados</option>
<option value="BY">Belarus</option>
<option value="BE">Belgium</option>
<option value="BZ">Belize</option>
<option value="BJ">Benin</option>
<option value="BM">Bermuda</option>
<option value="BT">Bhutan</option>
<option value="BO">Bolivia</option>
<option value="BA">Bosnia and Herzegowina</option>
<option value="BW">Botswana</option>
<option value="BV">Bouvet Island</option>
<option value="BR">Brazil</option>
<option value="IO">British Indian Ocean Territory</option>
<option value="BN">Brunei Darussalam</option>
<option value="BG">Bulgaria</option>
<option value="BF">Burkina Faso</option>
<option value="BI">Burundi</option>
<option value="KH">Cambodia</option>
<option value="CM">Cameroon</option>
<option value="CA">Canada</option>
<option value="CV">Cape Verde</option>
<option value="KY">Cayman Islands</option>
<option value="CF">Central African Republic</option>
<option value="TD">Chad</option>
<option value="CL">Chile</option>
<option value="CN">China</option>
<option value="CX">Christmas Island</option>
<option value="CC">Cocos (Keeling) Islands</option>
<option value="CO">Colombia</option>
<option value="KM">Comoros</option>
<option value="CG">Congo</option>
<option value="CD">Congo, the Democratic Republic of the</option>
<option value="CK">Cook Islands</option>
<option value="CR">Costa Rica</option>
<option value="CI">Cote d'Ivoire</option>
<option value="HR">Croatia (Hrvatska)</option>
<option value="CU">Cuba</option>
<option value="CY">Cyprus</option>
<option value="CZ">Czech Republic</option>
<option value="DK">Denmark</option>
<option value="DJ">Djibouti</option>
<option value="DM">Dominica</option>
<option value="DO">Dominican Republic</option>
<option value="TP">East Timor</option>
<option value="EC">Ecuador</option>
<option value="EG">Egypt</option>
<option value="SV">El Salvador</option>
<option value="GQ">Equatorial Guinea</option>
<option value="ER">Eritrea</option>
<option value="EE">Estonia</option>
<option value="ET">Ethiopia</option>
<option value="FK">Falkland Islands (Malvinas)</option>
<option value="FO">Faroe Islands</option>
<option value="FJ">Fiji</option>
<option value="FI">Finland</option>
<option value="FR">France</option>
<option value="FX">France, Metropolitan</option>
<option value="GF">French Guiana</option>
<option value="PF">French Polynesia</option>
<option value="TF">French Southern Territories</option>
<option value="GA">Gabon</option>
<option value="GM">Gambia</option>
<option value="GE">Georgia</option>
<option value="DE">Germany</option>
<option value="GH">Ghana</option>
<option value="GI">Gibraltar</option>
<option value="GR">Greece</option>
<option value="GL">Greenland</option>
<option value="GD">Grenada</option>
<option value="GP">Guadeloupe</option>
<option value="GU">Guam</option>
<option value="GT">Guatemala</option>
<option value="GN">Guinea</option>
<option value="GW">Guinea-Bissau</option>
<option value="GY">Guyana</option>
<option value="HT">Haiti</option>
<option value="HM">Heard and Mc Donald Islands</option>
<option value="VA">Holy See (Vatican City State)</option>
<option value="HN">Honduras</option>
<option value="HK">Hong Kong</option>
<option value="HU">Hungary</option>
<option value="IS">Iceland</option>
<option value="IN">India</option>
<option value="ID">Indonesia</option>
<option value="IR">Iran (Islamic Republic of)</option>
<option value="IQ">Iraq</option>
<option value="IE">Ireland</option>
<option value="IL">Israel</option>
<option value="IT">Italy</option>
<option value="JM">Jamaica</option>
<option value="JP">Japan</option>
<option value="JO">Jordan</option>
<option value="KZ">Kazakhstan</option>
<option value="KE">Kenya</option>
<option value="KI">Kiribati</option>
<option value="KP">Korea, Democratic People's Republic of</option>
<option value="KR">Korea, Republic of</option>
<option value="KW">Kuwait</option>
<option value="KG">Kyrgyzstan</option>
<option value="LA">Lao People's Democratic Republic</option>
<option value="LV">Latvia</option>
<option value="LB">Lebanon</option>
<option value="LS">Lesotho</option>
<option value="LR">Liberia</option>
<option value="LY">Libyan Arab Jamahiriya</option>
<option value="LI">Liechtenstein</option>
<option value="LT">Lithuania</option>
<option value="LU">Luxembourg</option>
<option value="MO">Macau</option>
<option value="MK">Macedonia, The Former Yugoslav Republic of</option>
<option value="MG">Madagascar</option>
<option value="MW">Malawi</option>
<option value="MY">Malaysia</option>
<option value="MV">Maldives</option>
<option value="ML">Mali</option>
<option value="MT">Malta</option>
<option value="MH">Marshall Islands</option>
<option value="MQ">Martinique</option>
<option value="MR">Mauritania</option>
<option value="MU">Mauritius</option>
<option value="YT">Mayotte</option>
<option value="MX">Mexico</option>
<option value="FM">Micronesia, Federated States of</option>
<option value="MD">Moldova, Republic of</option>
<option value="MC">Monaco</option>
<option value="MN">Mongolia</option>
<option value="MS">Montserrat</option>
<option value="MA">Morocco</option>
<option value="MZ">Mozambique</option>
<option value="MM">Myanmar</option>
<option value="NA">Namibia</option>
<option value="NR">Nauru</option>
<option value="NP">Nepal</option>
<option value="NL">Netherlands</option>
<option value="AN">Netherlands Antilles</option>
<option value="NC">New Caledonia</option>
<option value="NZ">New Zealand</option>
<option value="NI">Nicaragua</option>
<option value="NE">Niger</option>
<option value="NG">Nigeria</option>
<option value="NU">Niue</option>
<option value="NF">Norfolk Island</option>
<option value="MP">Northern Mariana Islands</option>
<option value="NO">Norway</option>
<option value="OM">Oman</option>
<option value="PK">Pakistan</option>
<option value="PW">Palau</option>
<option value="PA">Panama</option>
<option value="PG">Papua New Guinea</option>
<option value="PY">Paraguay</option>
<option value="PE">Peru</option>
<option value="PH">Philippines</option>
<option value="PN">Pitcairn</option>
<option value="PL">Poland</option>
<option value="PT">Portugal</option>
<option value="PR">Puerto Rico</option>
<option value="QA">Qatar</option>
<option value="RE">Reunion</option>
<option value="RO">Romania</option>
<option value="RU">Russian Federation</option>
<option value="RW">Rwanda</option>
<option value="KN">Saint Kitts and Nevis</option>
<option value="LC">Saint LUCIA</option>
<option value="VC">Saint Vincent and the Grenadines</option>
<option value="WS">Samoa</option>
<option value="SM">San Marino</option>
<option value="ST">Sao Tome and Principe</option>
<option value="SA">Saudi Arabia</option>
<option value="SN">Senegal</option>
<option value="SC">Seychelles</option>
<option value="SL">Sierra Leone</option>
<option value="SG">Singapore</option>
<option value="SK">Slovakia (Slovak Republic)</option>
<option value="SI">Slovenia</option>
<option value="SB">Solomon Islands</option>
<option value="SO">Somalia</option>
<option value="ZA">South Africa</option>
<option value="GS">South Georgia and the South Sandwich Islands</option>
<option value="ES">Spain</option>
<option value="LK">Sri Lanka</option>
<option value="SH">St. Helena</option>
<option value="PM">St. Pierre and Miquelon</option>
<option value="SD">Sudan</option>
<option value="SR">Suriname</option>
<option value="SJ">Svalbard and Jan Mayen Islands</option>
<option value="SZ">Swaziland</option>
<option value="SE">Sweden</option>
<option value="CH">Switzerland</option>
<option value="SY">Syrian Arab Republic</option>
<option value="TW">Taiwan, Province of China</option>
<option value="TJ">Tajikistan</option>
<option value="TZ">Tanzania, United Republic of</option>
<option value="TH">Thailand</option>
<option value="TG">Togo</option>
<option value="TK">Tokelau</option>
<option value="TO">Tonga</option>
<option value="TT">Trinidad and Tobago</option>
<option value="TN">Tunisia</option>
<option value="TR">Turkey</option>
<option value="TM">Turkmenistan</option>
<option value="TC">Turks and Caicos Islands</option>
<option value="TV">Tuvalu</option>
<option value="UG">Uganda</option>
<option value="UA">Ukraine</option>
<option value="AE">United Arab Emirates</option>
<option value="GB">United Kingdom</option>
<option value="US">United States</option>
<option value="UM">United States Minor Outlying Islands</option>
<option value="UY">Uruguay</option>
<option value="UZ">Uzbekistan</option>
<option value="VU">Vanuatu</option>
<option value="VE">Venezuela</option>
<option value="VN">Viet Nam</option>
<option value="VG">Virgin Islands (British)</option>
<option value="VI">Virgin Islands (U.S.)</option>
<option value="WF">Wallis and Futuna Islands</option>
<option value="EH">Western Sahara</option>
<option value="YE">Yemen</option>
<option value="YU">Yugoslavia</option>
<option value="ZM">Zambia</option>
<option value="ZW">Zimbabwe</option>
        </select>
      <label for="Country"></label></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">State:</td>
      <td><input type="text" name="state" value="<?php echo "$state"; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">City:</td>
      <td><input type="text" name="city" value="<?php echo "$city"; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Phone:</td>
      <td><input type="text" name="phone" value="<?php echo "$phone"; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Mobile:</td>
      <td><input type="text" name="mobile" value="<?php echo "$mobile"; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Business:</td>
      <td><input type="text" name="business" value="<?php echo "$business"; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Email:</td>
      <td><input type="text" name="email" value="<?php echo "$email"; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Website:</td>
      <td><input type="text" name="website" value="<?php echo "$website"; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right"> </td>
      <td><input type="submit" name="submit" value="Register" /></td>
    </tr>
      </form>
  </table>
<p> </p>
</body>
</html>

Link to comment
Share on other sites

There are numerous problems with the script.

 

Firstly, simply filtering data out of a users input without telling them is a bad idea. What is you end up changing there password? They would no longer be able to use it to login.

 

Secondly, all inputted data need to go through mysql_real_escape_string to make it safe for using within a database query.

 

Thirdly, your executing two SELECT queries against the same table, this could easily be done with one query.

 

Finally, your INSERT statement has a wildcard in it. This is incorrect syntax.

Link to comment
Share on other sites

There are numerous problems with the script.

 

Firstly, simply filtering data out of a users input without telling them is a bad idea. What is you end up changing there password? They would no longer be able to use it to login.

 

Secondly, all inputted data need to go through mysql_real_escape_string to make it safe for using within a database query.

 

Thirdly, your executing two SELECT queries against the same table, this could easily be done with one query.

 

Finally, your INSERT statement has a wildcard in it. This is incorrect syntax.

 

Thanks Thorpe:

 

I appreciate the advice, I'm pretty new to this "Doesn't Show Does It  :wtf: "  I will have to take what you said on-board and get to it when I figure out what's happening with this database.

 

It's like the databaes table doesn't exist?  Let me TRY to explain:

 

I have a database unclebob_unclebobrocks and it has 1 table named `members` 

 

(SELECT * FROM `members`LIMIT 0 , 30) copied from table

 

I made this to run a test and see what was happening

<?php 

require_once('connectDB.php');
mysql_query("INSERT INTO members (firstname, lastname, username, password, email, country, state, city) 
							   VALUES ('','John','Smith','Johnno','123456','john@abc.com','australia','queensland','brisbane')") or die(mysql_error());

?>

 

It returns error: No database selected

 

Like I said I'm pretty green when it comes to this stuff and I cant figure out  :wtf: is going on?  The members table exists to me because I can C it, but it seems like it doesn't exist in the computer abyss'?

 

Might I have screwed something up when I made the database?

 

Link to comment
Share on other sites

No database selected

 

Doesn't that suggest to you that you need to select a database?

 

Have you read through a basic php/mysql book or gone through a basic php/mysql tutorial? They all show connecting to a mysql database server, selecting a database, then executing a query.

 

You cannot execute queries for your data until you understand the code necessary to execute any query.

Link to comment
Share on other sites

No database selected

 

Doesn't that suggest to you that you need to select a database?

 

Have you read through a basic php/mysql book or gone through a basic php/mysql tutorial? They all show connecting to a mysql database server, selecting a database, then executing a query.

 

You cannot execute queries for your data until you understand the code necessary to execute any query.

HMMMM? I thought I had selected it, DAGNANGITMAN, 1 step forward 2 steps back. OH WELL, back to the drawing board. It's all about knowing where to start I guess?

Link to comment
Share on other sites

No database selected

 

Doesn't that suggest to you that you need to select a database?

 

Have you read through a basic php/mysql book or gone through a basic php/mysql tutorial? They all show connecting to a mysql database server, selecting a database, then executing a query.

 

You cannot execute queries for your data until you understand the code necessary to execute any query.

 

OK I'm 99% sure I have connected to the database using the

require_once ('connectDB.php');

<?php

$hostname_connectDB = "localhost";
$database_connectDB = "unclebob_unclebobrocks";
$username_connectDB = "my_username";
$password_connectDB = "Mypassword";
$connectDB = mysql_pconnect($hostname_connectDB, $username_connectDB, $password_connectDB)or trigger_error(mysql_error(),E_USER_ERROR); 
?>

 

The only table attached to this database is `members`

Link to comment
Share on other sites

Connecting and selecting are two different verbs and since computers only do exactly what their programming tells them to do, everything in a program has significance. You cannot effectively write a program that does what you want if you skip over learning the basics of what each instruction you are using does or reading what error messages tell you.

Link to comment
Share on other sites

You have connected to the database server, whilst you have stored the name of your database in $database_connectDB, does it not seem strange to you that you have not used it?

 

mysql_select_db

 

Thanks cags: That's the stuff, do you guys launch satellites in your spare time or what?

 

It's a dangerous man who is 100% certain he is right, when he is actually wrong...  :-[

Link to comment
Share on other sites

Connecting and selecting are two different verbs and since computers only do exactly what their programming tells them to do, everything in a program has significance. You cannot effectively write a program that does what you want if you skip over learning the basics of what each instruction you are using does or reading what error messages tell you.

 

Yep, I C your point, I knew this wouldn't be easy when I decided to make sail, but it's really like sailing into the mother of all storms using a canoe and a flanno shirt as the sail.

Link to comment
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.