HDFilmMaker2112 Posted July 14, 2011 Share Posted July 14, 2011 The below should be pulling credit information from the DB and placing it in the first select menu. It's not doing so. I did a var_dump on $_SESSION and the username and password match the DB. I'm assuming my problem is in my SQL query. <?php session_start(); $myusername=$_SESSION['myusername2']; $mypassword=$_SESSION['mypassword2']; require_once 'db_select.php'; require_once 'func.php'; $sql_credit="SELECT $tbl_name2.credit,$tbl_name.donor_id FROM $tbl_name JOIN $tbl_name2 WHERE $tbl_name.username='$myusername' AND $tbl_name.password='$mypassword' AND $tbl_name2.donor_id='$tbl_name.donor_id'"; $result_credit=mysql_query($sql_credit); $content=' <div class="main"> <div class="main_header">Purchase Additional Credit</div>'; if($_GET['e']==t){ $content.='<p class="green clear"> Request Sent. You should be contact with a discounted crew credit button specifically for you, in the next two business days. </p> '; } else{ $content.=' <p> If you wish to purchase an additional credit, use the form below to select the credit you wish to buy, the name in which the original credit is listed under (as listed on the donors page), and the e-mail address in which the original purchase came from. This is a great to get your name back on the top 100 donors list. Once you submit this form, we will review the submitted material, create a new paypal purchase button specifically for you, and send you the link to that button. From there, you will be able to purchase the additional credit.'; if($_GET['e']==f){ $content.='<p class="red"> The email address you entered doesn\'t match the email in the database for this account. Please try again. <br /> If you keep having problems, please contact us at <a href="mailto:general@makethemoviehappen.com"> general@makethemoviehappen.com</a>. </p>'; } $content.=' <form action="" method="post"> <p><label>Name Credit is Listed Under:</label> <input type="text" name="name" size="30" /></p> <p><label>E-Mail of Original Purchase:</label> <input type="text" name="email" size="32" /></p>'; $content.='<p><label>Original Credit Purchased:</label> <select name="credit"> <option value="">Select Credit</option>'."\n"; while($row_credits=mysql_fetch_array($result_credit)){ extract($row_credits); $content.='<option value="'.ucfirst($credit).'">'.ucfirst($credit).'</option>'."\n"; } $content.='</select></p>'."\n"; $content.=' <p><label>Second Credit to Purchase:</label> <select name="new_credit"> <option value="">Select Credit</option>'."\n"; while($row_credits=mysql_fetch_array($result_credit)){ extract($row_credits); $content.='<option value="'.ucfirst($credit).'">'.ucfirst($credit).'</option>'."\n"; } $content.='</select></p>'."\n".' </p> <p><input type="submit" value="Submit" name="Submit" /></p> </form> '; } $content.=" </div> <br />"; ?> Quote Link to comment Share on other sites More sharing options...
gristoi Posted July 14, 2011 Share Posted July 14, 2011 where are you declaring $tbl_name and $tblname2 ??????????? Quote Link to comment Share on other sites More sharing options...
HDFilmMaker2112 Posted July 14, 2011 Author Share Posted July 14, 2011 in db_select. <?php require_once './conn.php'; $db_name="zyquo_donors"; // Database name $tbl_name="donors"; // Table name $tbl_name2="donors_credits"; $tbl_name3="additional_donate"; $tbl_name4="credits_listing"; // Connect to server and select databse. mysql_connect("$host", "$db_username", "$db_password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); ?> Do I need to use "ON" somewhere in the query? Quote Link to comment Share on other sites More sharing options...
KevinM1 Posted July 14, 2011 Share Posted July 14, 2011 in db_select. <?php require_once './conn.php'; $db_name="zyquo_donors"; // Database name $tbl_name="donors"; // Table name $tbl_name2="donors_credits"; $tbl_name3="additional_donate"; $tbl_name4="credits_listing"; // Connect to server and select databse. mysql_connect("$host", "$db_username", "$db_password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); ?> Do I need to use "ON" somewhere in the query? http://dev.mysql.com/doc/refman/5.0/en/join.html Quote Link to comment Share on other sites More sharing options...
HDFilmMaker2112 Posted July 14, 2011 Author Share Posted July 14, 2011 I've read through the MySQL docs, and I have to say... the MySQL documentation is horribly written, or I guess the proper thing to say would be horribly formatted. Everything cluttered together, no separation of topics. I can''t really follow it. It's just a page of information with no clear distinction between points/topics. Quote Link to comment Share on other sites More sharing options...
jnvnsn Posted July 14, 2011 Share Posted July 14, 2011 http://www.tizag.com/mysqlTutorial/mysqljoins.php Quote Link to comment Share on other sites More sharing options...
HDFilmMaker2112 Posted July 14, 2011 Author Share Posted July 14, 2011 http://www.tizag.com/mysqlTutorial/mysqljoins.php I've read that too, and from that I'm not seeing that I'm doing anything wrong. Quote Link to comment Share on other sites More sharing options...
KevinM1 Posted July 14, 2011 Share Posted July 14, 2011 Yes, you need to use either "ON" or "USING" when you use the "JOIN" keyword. That's what the link I gave you specified. Quote Link to comment Share on other sites More sharing options...
HDFilmMaker2112 Posted July 15, 2011 Author Share Posted July 15, 2011 Well I changed it to this: $sql_credit="SELECT $tbl_name2.credit,$tbl_name.donor_id FROM $tbl_name JOIN $tbl_name2 ON $tbl_name2.donor_id='$tbl_name.donor_id' WHERE $tbl_name.username='$myusername' AND $tbl_name.password='$mypassword'"; Still no luck. It's working with USING. Thanks. Quote Link to comment Share on other sites More sharing options...
KevinM1 Posted July 15, 2011 Share Posted July 15, 2011 Are you getting any errors? Quote Link to comment Share on other sites More sharing options...
HDFilmMaker2112 Posted July 15, 2011 Author Share Posted July 15, 2011 Are you getting any errors? Not that I can see. This is working fine. $sql_credit="SELECT $tbl_name2.credit,$tbl_name.donor_id FROM $tbl_name JOIN $tbl_name2 USING (donor_id) WHERE $tbl_name.username='$myusername' AND $tbl_name.password='$mypassword'"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.