Jump to content

Recommended Posts

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 />";
?>

Link to comment
https://forums.phpfreaks.com/topic/241975-not-pulling-info-from-db/
Share on other sites

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?

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

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.

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.

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'";

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.