Jump to content

HDFilmMaker2112

Members
  • Posts

    547
  • Joined

  • Last visited

    Never

Posts posted by HDFilmMaker2112

  1. I'm pretty much taking over the MySQL sub-forum... lol.

    Sorry for so many threads guys, but this is the first time I've been this in depth in MySQL.

     

    The below is throwing the following error:

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/zyquo/public_html/ghosthuntersportal.com/product_process.php on line 33

     

    Line 33 is: while($row11=mysql_fetch_array($result11)){

     

    elseif($_GET['do']=="add"){
    $sql10="INSERT INTO $tbl_name (product_name, product_price, product_category, product_link, product_image, product_tag, product_features, product_pros, product_cons, product_description, product_notes) VALUES ('$product_name', '$product_price', '$product_category', '$product_link', '$product_image', '$product_tag', '$product_features', '$product_pros', '$product_cons', '$product_description', '$product_notes')";
    mysql_query($sql10);
    $sql11="SELECT product_id FROM $tbl_name WHERE product_name=".$product_name."";
    $result11=mysql_query($sql11);
    while($row11=mysql_fetch_array($result11)){
    $product_id2=$row11['product_id'];
    $sql12="INSERT INTO $tbl_name2 (keyword,product_id) VALUES ('$keyword','$product_id2')";
    mysql_query($sql12);
    }
    }
    

     

    query sql10 runs and inserts the data, query sql11 does not run.

  2. In ( 1, 2) is exactly the same as product_id = 1 OR product_id = 2.

     

    Your right, but that doesn't make much sense to me.

     

    To me OR would be a logical operator meaning it would pull only product_id=1 or product_id=2 based on some other argument in the code. Not pull both of them. That's at least the way it functions in PHP.

     

    Basically What I get out of using OR here is,

     

    WHERE product_id=1; pull product_id 1

    or

    WHERE product_id=2; pull product_id 2

     

    but never both, to me AND would mean pull both.

     

    Anyway, using IN() shortens my code.

  3. Here's my code:

     

    <?php
    $popular="product_id='1'"; //AND product_id='2' AND product_id='1' AND product_id='1' AND product_id='1'";
    $host="localhost"; // Host name 
    $username="username"; // Mysql username 
    $password="password"; // Mysql password 
    $db_name="zyquo_ghp"; // Database name 
    $tbl_name="products"; // Table name 
    
    // Connect to server and select databse.
    mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
    mysql_select_db("$db_name")or die("cannot select DB");
    
    $date_main="5/5/2011";
    $content='
    <div class="content_text">
    <div class="content_header">Welcome to Ghost Hunter\'s Portal</div>
    <p>We are real paranormal investigators selling equipment we use every week on investigations. 
    We offer email support for all of our products. We sell more than just ghost hunting equipment, so you can get all 
    your paranormal supplies all in one place. The advice on how to use the items we sell will be 
    answered by real researchers. These are the tools that we personally use regularly on investigations, so we won\'t 
    sell anything that doesn\'t work properly in the field.</p>
    
    <p>We not only focus on gearing paranormal groups, but also individuals. If you believe you\'re sharing space with 
    an entity, let us help you find out for sure. Whether you\'re a staunch believer, a hardcore skeptic or just curious 
    about ghost hunting, our equipment line features just the ghost hunting tools you\'ll need on your quest for answers.</p>
    <br />
    <div class="content_header">Our Popular Products</div>
    <div class="popular_products">';
    $sql="SELECT * FROM $tbl_name WHERE $popular";
    $result=mysql_query($sql);
    while($row=mysql_fetch_array($result)){
    $product_category=$row['product_category'];
    $content.='<div class="popular_item">'.$product_category.'</div>'."\n";
    }
    $content.='
    </div>
    </div>
    ';
    ?>
    

     

    When I alter this (which works):

     

    $popular="product_id='1'"; //AND product_id='2' AND product_id='1' AND product_id='1' AND product_id='1'"; 
    

     

    to this:

     

    $popular="product_id='1' AND product_id='2'"; // AND product_id='1' AND product_id='1' AND product_id='1'";
    

     

    This doesn't work. It returns no values at all. I know for a fact that there are product_ids of both 1 and 2.

  4. Actually... never mind, no I didn't.

     

    What should I be doing exactly. I tried a few different things; including putting an if statement just around the $_SESSION

     

    i.e;

    if($_POST['username']=="username" && $_POST['password']=="password"){
    $_SESSION['username']=$_POST['username'];
    $_SESSION['password']=$_POST['password'];
    }
    

    that made it work except the log-out portion was no longer working. So what exactly should I be doing and where should I be placing it to keep everything functioning?

  5. I'm having issues with the following:

     

    <?php
    session_start();
    $_SESSION['username']=$_POST['username'];
    $_SESSION['password']=$_POST['password'];
    if($_SESSION['username']=="username" && $_SESSION['password']=="password"){
    if($_GET['product']=="add"){
    $content.='
    <p><label>Product Name:</label> <input type="text" name="product_name" size="30" />
    <label>Product Price:</label> <input type="text" name="product_price" size="5" />
    </p>
    <p><label>Product Category:</label> <input type="text" name="product_category" size="30" /></p>
    <p><label>Product Link:</label> <input type="text" name="product_link" size="30" /></p>
    <p><label>Product Image:</label> <input type="text" name="product_image" size="30" /></p>
    <p><label>Product Tag:</label> <input type="text" name="product_tag" size="30" /></p>
    <p><label>Product Keywords:</label> <input type="text" name="keyword" size="30" /></p>
    <p><label>Product Features:</label><br />
    <textarea name="product_features" rows="10" cols="60"></textarea>
    </p>
    <p><label>Product Pros:</label><br />
    <textarea name="product_pros" rows="5" cols="30"></textarea>
    </p>
    <p><label>Product Cons:</label><br />
    <textarea name="product_cons" rows="5" cols="30"></textarea>
    </p>
    <p><label>Product Description:</label><br />
    <textarea name="product_description" rows="10" cols="60"></textarea>
    </p>
    <p><label>Product Notes:</label><br />
    <textarea name="product_notes" rows="5" cols="30"></textarea>
    </p>
    ';
    $logout='<div><a href="./acp_admincp.php?log-out">Log-Out</a></div>';
    }
    elseif($_GET['product']=="view"){
    }
    else{
    $content.='
    <a href="./admincp.php?product=add">Add New Product</a>
    <br />
    <a href="./admincp.php?product=view">View Products</a>
    ';
    }
    }
    elseif(isset($_GET['log-out'])){
    session_start();
    session_unset();
    session_destroy();
    header("Location: ./admincp.php");
    }
    else{
    $content='
    <form action="./admincp.php" method="post">
    <p><label>Username:</label> <input type="text" name="username" size="30" />';
    $content.='</p>
    <p><label>Password:</label> <input type="password" name="password" /></p>';
    $content.='<p><input type="submit" value="Submit" name="Submit" /></p>
    </form>';
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 
    <head>
    <base href="http://ghosthuntersportal.com/" />
    <title>Ghost Hunter's Portal - Admin Control Panel</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta name="verify-v1" content="" />
    <meta name="keywords" content="ghost, hunters, hunter, ghosts, spirit, spirits, paranormal, investigation, investigator, investigators, k2, emf, meter, kii" />
    <meta name="description" content="Ghost Hunters Potal. Parnormal research equipment store." />
    <meta name="author" content="Andrew McCarrick" />
    <meta name="robots" content="index, follow" 
    <link rel="stylesheet" type="text/css" href="style.css" />
    </head>
    <body>
    <img src="./logo.png" alt="Ghost Hunter's Portal Admin Control Panel" />
    <br />
    <div style="color: #AA44AA; font-size: 26px; margin-top: -30px; margin-left: 125px;">Admin Control Panel</div>
    <?php
    echo $logout;
    echo $content;
    ?>
    </body>
    </html>
    

     

    I can log-in, and get to the page with the two links on it. However, once I click one of the links it falls back to the log-in page, and it ends up being a never ending loop.

     

    It's doing this:

    Log-In --> Page with links ---> Log-In page again

     

    Should be doing this:

    Log-In --> Page with links --> Add Product page or View Products page

     

    I can never get into the the actual sub page.

     

    Just to be clear, the address bar actually shows product=add or product=view, but it still shows the log-in page.

  6. Alright, I read over that other thread.

     

    I'm curious what the difference would be between separating each item out like that, or keeping them in all in one field with commas, and then later exploding them out in php. It would seem to me doing the explode with php would reduce strain on the database system, but I may end up putting more pressure on the server to process the explode.

     

    So speaking in using server resources as effectively as possible, which one would be better? Separated out database or a combined database field with a php explode.

     

    So separated database entries versus this:

     

    $sql1="SELECT * FROM $tbl_name WHERE keyword_number='1'";
    $result1=mysql_query($sql1);
    
    
    $row=mysql_fetch_row($result1);
    $product_ids=$row['product_ids']
    
    $product_ids=explode(",","$product_ids")
    

     

  7. I'm programming a store right now... I have three tables set-up; one for the products, one for search keywords and the other for customer reviews.

     

    My keywords table has keyword_number aka keyword id, keyword, and product_ids.

     

    each keyword will contain the product_id of the products that should go under that keyword. Now when I program my admin panel to add products, how do I update the specific product_ids field under the specific keyword.

     

    For example say I have:

     

    1 | audio | 1,3,5,7,19,30,53

    2 | meter |2,5,6,8,20,35,46,53

    3 | microphone | 1,3,6,20,46,53

    4 | computer | 4, 9, 10,13,15,17

     

    Now Say I add a new product, that is assigned a product_id of 54 under the products table... How do I update the keywords table, without wiping the current products in there? Say I add it under the keywords audio and microphone.

     

    I need this:

    1 | audio | 1,3,5,7,19,30,53

    3 | microphone | 1,3,6,20,46,53

     

    to become this:

    1 | audio | 1,3,5,7,19,30,53,54

    3 | microphone | 1,3,6,20,46,53,54

     

    Do I have to pull the data out of the field and then replace all of it with the 54 concatenation onto the end?

    Or can I some how write a MySQL statement to just concatenation 54 right on to the end of the field, without pulling the data out to replace it again later with the same info, with 54 added?

  8. Alright I noticed one of my errors.

     

    I didn't have http_built_query assigned to a vaiable.... changed that. Now it's passing:

     

    /index.php?investors=register2&error=6=1

     

    Where I want it to basically base a 7-bit binary code.

     

    /index.php?investors=register2&error=1010111

     

    So on the original page I can pull the 0s and 1s from the url and trigger the proper error messages.

     

    <?php
    $host="localhost"; // Host name 
    $username="username"; // Mysql username 
    $password="password"; // Mysql password 
    $db_name="dbname"; // Database name 
    $tbl_name="application"; // Table name 
    
    // Connect to server and select databse.
    mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
    mysql_select_db("$db_name")or die("cannot select DB");
    
    $error= array();
    $name=$_POST['name'];
    $name = stripslashes($name);
    $name = mysql_real_escape_string($name);
    if(!isset($name)){
    $error[0]=1;
    }
    else{
    $error[0]=0;
    }
    
    $organization=$_POST['organization'];
    $organization = stripslashes($organization);
    $organization = mysql_real_escape_string($organization);
    
    $email=$_POST['email'];
    $email = stripslashes($email);
    $email = mysql_real_escape_string($email);
    if(!isset($email)){
    $error[1]=1;
    }
    else{
    $error[1]=0;
    }
    
    $area_code=$_POST['area_code'];
    $area_code = stripslashes($area_code);
    $area_code = mysql_real_escape_string($area_code);
    if(!isset($area_code) || is_int($area_code)){
    $error[2]=1;
    }
    else{
    $error[2]=0;
    }
    
    $phone3=$_POST['phone3'];
    $phone3 = stripslashes($phone3);
    $phone3 = mysql_real_escape_string($phone3);
    if(!isset($phone3) || is_int($phone3)){
    $error[3]=1;
    }
    else{
    $error[3]=0;
    }
    
    $phone4=$_POST['phone4'];
    $phone4 = stripslashes($phone4);
    $phone4 = mysql_real_escape_string($phone4);
    if(!isset($phone4) || is_int($phone4)){
    $error[4]=1;
    }
    else{
    $error[4]=0;
    }
    
    $ext=$_POST['ext'];
    $ext = stripslashes($ext);
    $ext = mysql_real_escape_string($ext);
    
    $phone="(".$area_code.") ".$phone3." - ".$phone4." Ext. ".$ext."";
    
    $company_description=$_POST['company_description'];
    $company_description = stripslashes($company_description);
    $company_description = mysql_real_escape_string($company_description);
    
    $nature_inquiry=$_POST['nature_inquiry'];
    $nature_inquiry = stripslashes($nature_inquiry);
    $nature_inquiry = mysql_real_escape_string($nature_inquiry);
    if(!isset($nature_inquiry)){
    $error[5]=1;
    }
    else{
    $error[5]=0;
    }
    
    $company_assets=$_POST['company_assets'];
    $natural_person=$_POST['natural_person'];
    $employee_benefit_plan=$_POST['employee_benefit_plan'];
    
    $bank_savings=$_POST['bank_savings'];
    $broker_dealer=$_POST['broker_dealer'];
    $development_company=$_POST['development_company'];
    $equity_owners=$_POST['equity_owners'];
    $confirm_agreement=$_POST['confirm_agreement'];
    if($confirm_agreement=="no"){
    $error[6]=1;
    }
    else{
    $error[6]=0;
    }
    
    if($employee_benefit_plan=="plan-fiduciary"){
    $employee_benefit_plan="The investment decision is being made by a plan fiduciary, as defined in Section 3(21) of 
    ERISA, which is either a bank, savings and loan association, insurance company or registered investment adviser";
    }
    elseif($employee_benefit_plan=="participant-directed"){
    $employee_benefit_plan="It is a participant-directed plan (i.e., a tax-qualified defined contribution plan in 
    which a participant may exercise control over the investment of assets credited to his or her account and the 
    decision to invest is made by those participants investing) and each such participant qualifies as an accredited 
    investor.";
    }
    elseif($employee_benefit_plan=="na"){
    $employee_benefit_plan="Neither of the Above.";
    }
    
    if(isset($error)){
    $error=http_build_query($error);
    header("Location: ./index.php?investors=register2&error=".$error."");
    }
    else{
    $sql="INSERT INTO $tbl_name VALUES ('$name', '$organization', '$email', '$phone', '$company_description', 
    '$nature_inquiry', '$company_assets', '$natural_person', '$employee_benefit_plan', '$bank_savings', 
    '$broker_dealer', '$development_company', '$equity_owners', '$confirm_agreement')";
    mysql_query($sql);
    }
    ?>
    

  9. try using http_build_query  instead of encoding the serialized array.

     

    Alright, I get the following return:

    Warning: http_build_query() [function.http-build-query]: Parameter 1 expected to be Array or Object. Incorrect value given in /home/zyquo/public_html/makethemoviehappen.com/investors_application_process.php on line 99

     

     

    if(isset($error)){
    http_build_query(serialize($error));
    header("Location: ./index.php?investors=register2&error=".$error."");
    }
    

  10. I'm having a problem with passing the error checking in this script into the url. It's basically checking to see if the entry has a value and if doesn't give an error messaage.  All the error messages (technically a error number to trigger the error message on the original page) should be combined into one array, and sent via the URL so the original page can get the information from the URL. All it produces right now is index.php?investors=register2&error=array. I thought serializing the array should stop that from happening.

     

    <?php
    $host="localhost"; // Host name 
    $username="username"; // Mysql username 
    $password="password"; // Mysql password 
    $db_name="db_name"; // Database name 
    $tbl_name="application"; // Table name 
    
    // Connect to server and select databse.
    mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
    mysql_select_db("$db_name")or die("cannot select DB");
    
    $error= array();
    
    $name=$_POST['name'];
    $name = stripslashes($name);
    $name = mysql_real_escape_string($name);
    if(!isset($name)){
    $error[0]=1;
    }
    
    $organization=$_POST['organization'];
    $organization = stripslashes($organization);
    $organization = mysql_real_escape_string($organization);
    
    $email=$_POST['email'];
    $email = stripslashes($email);
    $email = mysql_real_escape_string($email);
    if(!isset($email)){
    $error[1]=1;
    }
    
    $area_code=$_POST['area_code'];
    $area_code = stripslashes($area_code);
    $area_code = mysql_real_escape_string($area_code);
    if(!isset($area_code) || is_int($area_code)){
    $error[2]=1;
    }
    
    $phone3=$_POST['phone3'];
    $phone3 = stripslashes($phone3);
    $phone3 = mysql_real_escape_string($phone3);
    if(!isset($phone3) || is_int($phone3)){
    $error[3]=1;
    }
    
    $phone4=$_POST['phone4'];
    $phone4 = stripslashes($phone4);
    $phone4 = mysql_real_escape_string($phone4);
    if(!isset($phone4) || is_int($phone4)){
    $error[4]=1;
    }
    
    $ext=$_POST['ext'];
    $ext = stripslashes($ext);
    $ext = mysql_real_escape_string($ext);
    
    $phone="(".$area_code.") ".$phone3." - ".$phone4." Ext. ".$ext."";
    
    $company_description=$_POST['company_description'];
    $company_description = stripslashes($company_description);
    $company_description = mysql_real_escape_string($company_description);
    
    $nature_inquiry=$_POST['nature_inquiry'];
    $nature_inquiry = stripslashes($nature_inquiry);
    $nature_inquiry = mysql_real_escape_string($nature_inquiry);
    if(!isset($nature_inquiry)){
    $error[5]=1;
    }
    
    
    $company_assets=$_POST['company_assets'];
    $natural_person=$_POST['natural_person'];
    $employee_benefit_plan=$_POST['employee_benefit_plan'];
    $bank_savings=$_POST['bank_savings'];
    $broker_dealer=$_POST['broker_dealer'];
    $development_company=$_POST['development_company'];
    $equity_owners=$_POST['equity_owners'];
    $confirm_agreement=$_POST['confirm_agreement'];
    if($confirm_agreement=="no"){
    $error[6]=1;
    }
    
    if($employee_benefit_plan=="plan-fiduciary"){
    $employee_benefit_plan="The investment decision is being made by a plan fiduciary, as defined in Section 3(21) of 
    ERISA, which is either a bank, savings and loan association, insurance company or registered investment adviser";
    }
    elseif($employee_benefit_plan=="participant-directed"){
    $employee_benefit_plan="It is a participant-directed plan (i.e., a tax-qualified defined contribution plan in 
    which a participant may exercise control over the investment of assets credited to his or her account and the 
    decision to invest is made by those participants investing) and each such participant qualifies as an accredited 
    investor.";
    }
    elseif($employee_benefit_plan=="na"){
    $employee_benefit_plan="Neither of the Above.";
    }
    
    
    if(isset($error)){
    rawurlencode(serialize($error));
    header("Location: ./index.php?investors=register2&error=".$error."");
    }
    else{
    $sql="INSERT INTO $tbl_name VALUES ('$name', '$organization', '$email', '$phone', '$company_description', '$nature_inquiry', '$company_assets', '$natural_person', '$employee_benefit_plan', '$bank_savings', '$broker_dealer', '$development_company', '$equity_owners', '$confirm_agreement')";
    mysql_query($sql);
    }
    ?>

  11. Post the revised code snippet . . .

     

    hmm... I was using

    if($num_rows==1){
    $sql1="UPDATE $tbl_name SET Password='$new_password' WHERE Username='$username' AND Email='$email' AND Amount='$donation_amount'";
    $result1=mysql_query($sql1);
    $num_rows1=mysql_affected_rows($result1);
    

     

    I switched it to

    $num_rows1=mysql_affected_rows();
    

    without $result1 inside the parenthesis and now it's working.

     

    Any idea why it wasn't working with the variable in it?

     

    And thanks by the way for the correction to mysql_affected_rows... first time I needed to calculate rows based on a database update.

  12. Alright, tried mysql_affected_rows(); still same error, except it says:

     

    Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in /home/zyquo/public_html/makethemoviehappen.com/forgot_password.php on line 89

     

     

    (Updated first post with new code.)

  13. I'm having a little issue with this script. It's returning:

     

    "Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/zyquo/public_html/makethemoviehappen.com/forgot_password.php on line 89"

    (Line 89 is: $num_rows1 = mysql_num_rows($result1);)

     

    and

     

    "New password could not be generated. If you continue to have issues, please email general@makethemoviehappen.com for assistance."

     

    I checked the database and the random password generation did run, and it was inserted into the database. So it's just not detecting that it ran, so it's not sending the email. Any ideas on why?

     

    I also checked what is returned in the $result1 variable and it's the number 1.

     

     

    elseif($_GET['forgot']=="password"){ 
    
    function &generatePassword($length=9, $strength=0) { 
            $vowels = 'aeiuy'; 
            $consonants = 'bcdfghjkmnpqrstwz'; 
            if ($strength & 1) { 
                    $consonants .= 'BCDFGJLMNPQRSTVXZ'; 
            } 
            if ($strength & 2) { 
                    $vowels .= "AEIUY"; 
            } 
            if ($strength & 4) { 
                    $consonants .= '23456789'; 
            } 
            if ($strength &  { 
                    $consonants .= '@#$%'; 
            } 
      
            $password = ''; 
            $alt = time() % 2; 
            for ($i = 0; $i < $length; $i++) { 
                    if ($alt == 1) { 
                            $password .= $consonants[(rand() % strlen($consonants))]; 
                            $alt = 0; 
                    } else { 
                            $password .= $vowels[(rand() % strlen($vowels))]; 
                            $alt = 1; 
                    } 
            } 
            return $password; 
    } 
    
    $new_password =& generatePassword(); 
    
    $username=$_POST['username']; 
    $sql="SELECT * FROM $tbl_name WHERE Username='$username' AND Email='$email' AND Amount='$donation_amount'"; 
    $result=mysql_query($sql); 
    $num_rows = mysql_num_rows($result); 
    
    if($num_rows==1){ 
    $sql1="UPDATE $tbl_name SET Password='$new_password' WHERE Username='$username' AND Email='$email' AND Amount='$donation_amount'"; 
    $result1=mysql_query($sql1); 
    $num_rows1 = mysql_affected_rows($result1); 
    
    if($num_rows1==1){ 
    $content.='<p class="center">New password generated. It has been emailed to the email address provided.</p><br />'; 
    $message='Some one (hopefully you) requested a new password be generated for your account on Make the Movie Happen. 
    Below is the newly generated password: 
    
    Password: '.$new_password.' 
    
    Once you log-in, please change your password. 
    
    Thank You, 
    Make the Movie Happen Support Team 
    '; 
    mail($email, 'Make the Movie Happen - New Password', $message, 'From: general@makethemoviehappen.com'); 
    } 
    
    else{ 
    $content.='New password could not be generated.  
    If you continue to have issues, please email <a href="mailto:general@makethemoviehappen.com">general@makethemoviehappen.com</a> for assistance.'; 
    } 
    
    } 
    else{ 
    header("Location: ./index.php?forgot&e=1"); 
    } 
    }
    

×
×
  • 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.