Jump to content

mallen

Members
  • Posts

    316
  • Joined

  • Last visited

Everything posted by mallen

  1. No edit button so I have to post again. I meant for Model 1 to show twice.
  2. I am trying to get the item to list multiple times like this. <div class="productHolder"> <div class="mainThumbnail"> <img src="http://www......." alt="MainThumbnail"> </div> <h3>Product Name Appear here</h3> <h5>Model : Model#1 here <small>(Company 1)</small></h5> <span class="viewBtn"> <a href="?page_id=169&company=95&singleProduct=1628"><img src="http://www......./products/_images/x.png" alt="Click to View" height="18" width="137"></a> </span> </div> <div class="productHolder"> <div class="mainThumbnail"> <img src="http://www......." alt="MainThumbnail"> </div> <h3>Product Name Appear here</h3> <h5>Model : Model#2 here <small>(Company 2)</small></h5> <span class="viewBtn"> <a href="?page_id=169&company=100&singleProduct=1629"><img src="http://www......./products/_images/x.png" alt="Click to View" height="18" width="137"></a> </span> </div>
  3. Ok sorry this might clear up my issue. If two companies appear in the query with the item, The item name and company will be a one link and the second company will be second link. Its combining the item name and company in the hyperlink.
  4. Thank you so much. I did realize the original ifelse statement was where my problem was. I am following what someone else set up and do agree its a mess. Now here is what I got so far using your code. It will list the item like this: Image name and model. Then it will list (company 1) (Company 2) And the second company will always have a hyperlink link on it. The good news is its reading all the records now. I would like to either get the hyperlink on the second company name or better yet list the item again with name, image, and another hyperlink.
  5. Thanks for the reply. Yes I know its not ideal. The reason the 3rd company is separate is because the data is entered in a separate form. The product numbers, description and everything has to be entered separate becuase of metric measurements and descriptions. So I need for all three listing to show if the item is contained in all three companies.
  6. I have a search I am doing n a large list of products. When products are entered they are assigned to three different "divisions of the company such as company1, cpmpany2 and company3. When I do a search it displays the product description and includes what company is associated with. But If the same item is listed in two companies it will only display 1 company. I have tested with either company name and have decided this is the issue. Here is the code I have for the search. I don't see anything keeping duplicated from showing. $searchRequest = strtolower($_REQUEST['searchQuery']); $formQuery = "SELECT cat.cat_name, cat.cat_id, prod.prod_id, prod.prod_name,prod.prod_mainImage, prod.prod_model, prod_company1, prod_company2, prod_company3 FROM products AS prod LEFT JOIN category_assoc AS assoc ON assoc.prod_id = prod.prod_id LEFT JOIN categories AS cat ON cat.cat_id = assoc.cat_id WHERE LOWER(prod.prod_name) LIKE '%". $searchRequest ."%' OR LOWER(prod.prod_model) LIKE '%". $searchRequest ."%' OR LOWER(cat.cat_name) LIKE '%". $searchRequest ."%' OR LOWER(prod.prod_description) LIKE '%". $searchRequest. "%' ORDER BY prod.prod_name ASC"; $results = $wpdb->get_results($formQuery, ARRAY_A); get_header(); ?> <div id="mainContent"> <div id='interiorLeft'> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <h2><?php the_title();?> For <?php echo $searchRequest; ?></h2> <?php the_content(); ?> <?php endwhile; endif; ?> <hr/> <?php if(count($results) > 0) : foreach($results as $res) { $prImage = $res['prod_mainImage']; if(empty($res['prod_mainImage'])) $prImage = "noImage.png"; if($res['prod_company3'] == 1) { $theCompany = "100"; $theName = "Company3"; } elseif($res['prod_company2'] == 1) { $theCompany = "95"; $theName = "Company 2"; } else { $theCompany = "15"; $theName = "Company 1"; } ?> <div class='productHolder'> <div class='mainThumbnail'> <img src='<?php echo PRODUCT_IMAGE . "/thumbnails/". $prImage;?>' alt='MainThumbnail' /> </div> <h3><?php echo stripslashes($res['prod_name']);?></h3> <h5>Model : <?php echo $res['prod_model']; ?> <small>(<?php echo $theName;?>)</small></h5> <span class='viewBtn'> <a href='?page_id=169&company=<?php echo $theCompany;?>&singleProduct=<?php echo $res['prod_id'];?>'>
  7. Perfect, thank you. Now that I know what they are called I can read up on them.
  8. I came across these pieces of code and have been trying to understand this operator -> Or if it is a operator. I have searched and couldn't find explanations. In trying to learn I need to know what is is used for. Is it used only with classes? $m->myMethod(); return $this->x;
  9. Well yeah I could but I know for example there is a plug in for WordPress that allows you to do make it look like this http://www.free-php.net/830/wordpress-custom-field-image-to-featured-image/ but I am not using WordPress. I know this board uses Code tags. This is what they are using http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/php.html
  10. How can I post PHP code on my website and style like this? http://www.9lessons.info/2010/02/php-login-script-with-encryption.html http://www.free-php.net/830/wordpress-custom-field-image-to-featured-image/
  11. Thanks for your replies. This is what I came up with before I saw the replies. Is there any benefit to using an array over the way I did it? (more text fields above this) $county = $_POST['county']; $to = $county; switch ($to) { case ($to =='County1' || $to == 'County2' || $to == 'County3'): $to = "[email protected]"; break; case ($to == 'County4' || $to == 'County5' || $to == 'County6'): $to = "[email protected]"; break; default: $to = "[email protected]"; }
  12. I have a form that emails the content to a recipient. Now I want to direct the email to 6 different recipients based on the county they select. I got it to work with just two counties (cases). But my state has over 60 counties and I will be dividing by about 10 counties each. Is there a way to list 10 counties for each case? This is what I have. switch ($to) { case 'County1': $to = "[email protected]"; break; case 'County2': $to = "Bob@mysite"; break; default: $to = "[email protected]"; }
  13. Ok I got it working, sort of... getting this error .....mysqli_real_escape_string() expects exactly 2 parameters, So I just removed the mysqli_real_escape_string() and now it is the following and working: $username = trim($_POST['user']); $password = trim($_POST['password']); Why does it throw that error?
  14. Yes I know but I use the same connection for other pages i work on. I moved the $con = dbConnect(); line. Still not working. <?php $con = dbConnect(); $username = mysql_real_escape_string(trim($_POST['user'])); $password = mysql_real_escape_string(trim($_POST['password'])); $sql = "SELECT * FROM users WHERE username = '$username' and password = '$password'"; $result = $con->query($sql) or die(mysql_error()); echo $row['username']; $row = $result->fetch_assoc(); if(!empty($_POST['submit'])){ if($username == "") { print "Please enter your username"; }elseif($password == "") { print "Please enter your password"; }elseif($username == $row['username'] && $password == $row['password'] ){ // Check if username and password were submitted if (!isset($_SESSION['user'])){ session_regenerate_id(); //assign user's name to session } $_SESSION['user'] = $_POST['user']; } } ?> <?php if(($_SESSION['user'] == "" )|| (!isset($_SESSION['user']))){ ?> <form action="login9.php" method="post"> <table width="200" border="0"> <tr> <td width="71">User:</td> <td width="113"><label for="user"></label> <input type="text" name="user" id="user" /></td> </tr> <tr> <td>Password:</td> <td><label for="password"></label> <input type="password" name="password" id="password" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" value="Log in" /></td> </tr> </table> </form> <?php }else{ print "Hello, ".$_SESSION['user']; }?>
  15. <?php function dbConnect() { $con = mysqli_connect('localhost', 'root','xxxx', 'development') or die ('Cannot connect to MySQL server'); return $con; } ?>
  16. I have this simple form checking a user and password from database. At first I was just checking a hard coded value. Now I want to check it against the database. Is there anything in my code that is keeping it form working? You can point to me and I can try to figure it out? Warning: mysql_real_escape_string(): Access denied for user ''@'localhost' (using password: NO) in ...... Warning: mysql_real_escape_string(): A link to the server could not be established in.... Warning: mysql_real_escape_string(): Access denied for user ''@'localhost' (using password: NO) in .... Warning: mysql_real_escape_string(): A link to the server could not be established in .... <?php session_start(); error_reporting(E_ALL ^ E_NOTICE); include('../includes/dev.connection.inc.php'); ?> <!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>Login Test Page</title> </head> <body> <?php $username = mysql_real_escape_string(trim($_POST['user'])); $password = mysql_real_escape_string(trim($_POST['password'])); $con = dbConnect(); $sql = "SELECT * FROM users WHERE username = '$username' and password = '$password'"; $result = $con->query($sql) or die(mysql_error()); echo $row['username']; $row = $result->fetch_assoc(); if(!empty($_POST['submit'])){ if($username == "") { print "Please enter your username"; }elseif($password == "") { print "Please enter your password"; }elseif($username == $row['username'] && $password == $row['password'] ){ // I Think this line is giving me the error // Check if username and password were submitted if (!isset($_SESSION['user'])){ session_regenerate_id(); //assign user's name to session } $_SESSION['user'] = $_POST['user']; } } ?> <?php if(($_SESSION['user'] == "" )|| (!isset($_SESSION['user']))){ ?> <form action="login9.php" method="post"> <table width="200" border="0"> <tr> <td width="71">User:</td> <td width="113"><label for="user"></label> <input type="text" name="user" id="user" /></td> </tr> <tr> <td>Password:</td> <td><label for="password"></label> <input type="password" name="password" id="password" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" value="Log in" /></td> </tr> </table> </form> <?php }else{ print "Hello, ".$_SESSION['user']; }?> </body> </html>
  17. Ahh perfect. Thanks so much phpSensei. Now I will work on a mysql connection instead of a hardcoded user and password. Also will work on SQL injections. I know it would have been easier to just send the user to a "welcome" page but it was a learning experience using errors, conditions, and sessions.
  18. When I enter the form, it should display "You are logged in me". But as it is now the screen goes blank, then if you refresh the screen the message shows.
  19. I don't get an error, but the form goes away, then I refresh the screen and it says I'm logged in.
  20. Notice: Undefined index: user in .....on line 41 if(($_SESSION['user'] == "" )|| (!isset($_SESSION['user']))){ ?>
  21. Parse error: syntax error, unexpected $end on last line
  22. Phpsensei, Thanks again for all your help. I think I'm getting closer. It prints the user's name but still shows the form if they are signed in. <?php session_start(); ?> <!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>Login Test Page</title> </head> <body> <?php if(!empty($_POST['submit'])){ $user = trim($_POST['user']); $password = trim($_POST['password']); if($user == "") { print "Please enter your username"; }elseif($password == "") { print "Please enter your password"; }elseif($user == "me" && $password == "test"){ // Check if username and password were submitted if (!isset($_SESSION['user'])){ session_regenerate_id(); //assign user's name to session $_SESSION['user'] = $_POST['user']; }elseif($_SESSION['user'] = "me"){ print '<p>You are logged in ' . $_SESSION['user'] . ' !</p>'; } } } ?> <form action="login5.php" method="post"> <table width="200" border="0"> <tr> <td width="71">User:</td> <td width="113"><label for="user"></label> <input type="text" name="user" id="user" /></td> </tr> <tr> <td>Password:</td> <td><label for="password"></label> <input type="password" name="password" id="password" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" value="Log in" /></td> </tr> </table> </form> </body> </html>
  23. Thanks I didn't even occur to me I should have caught that. Yes I am just testing to work with operators, errors etc. Now that its working I have one more fix. Once I am logged I don't want to show the form.
  24. I still get errors. I changed username to user Warning: mysql_real_escape_string(): Access denied for user ''@'localhost' (using password: NO) in C:\inetpub..... on line 13 Warning: mysql_real_escape_string(): A link to the server could not be established in C:\inetp..... on line 13 Warning: mysql_real_escape_string(): Access denied for user ''@'localhost' (using password: NO) in C:\inetp...... on line 14 Warning: mysql_real_escape_string(): A link to the server could not be established in C:\inetp..... on line 14 Please enter your username
  25. I tried something like this but still getting errors. <?php if(!empty($_POST['submit'])){ $username = mysql_real_escape_string(trim($_POST['user'])); $password = mysql_real_escape_string(trim($_POST['password'])); if(($username == "") || ($username !== "me")) { print "Please enter your username"; }elseif(($password == "") || ($password !== "test")){ print "Please enter your password"; }else{ // Username and password havebeen submitted print '<p>You are logged in</p>'; } } ?>
×
×
  • 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.