ballhogjoni Posted August 13, 2007 Share Posted August 13, 2007 if ($row['Username'] == $Username && $row['title'] == $title_checked && $row['description'] == $desc_checked && $row['price'] == $price) { Quote Link to comment https://forums.phpfreaks.com/topic/64600-waht-is-wrong-with-this-line-of-code/ Share on other sites More sharing options...
Fadion Posted August 13, 2007 Share Posted August 13, 2007 Nothing's wrong. What error are u getting and maybe u can post a bit more code. Quote Link to comment https://forums.phpfreaks.com/topic/64600-waht-is-wrong-with-this-line-of-code/#findComment-322086 Share on other sites More sharing options...
ballhogjoni Posted August 13, 2007 Author Share Posted August 13, 2007 lol its not showing my code i posted. if ($row['Username'] == $Username && $row['title'] == $title_checked && $row['description'] == $desc_checked && $row['price'] == $price) { if (isset($_POST['submit'])) { if (isset($_POST['title']) && isset($_POST['desc']) && isset($_POST['price'])) { $title_checked = strip_tags($_POST['title']); $desc_checked = strip_tags($_POST['desc']); $price = $_POST['price']; if (!empty($title_checked) && !empty($desc_checked) && !empty($price)) { $query = mysql_query("SELECT Username, title, description, price FROM products WHERE Username = '$Username'") or die(mysql_error)); $row = mysql_fetch_array($query) or die(mysql_error)); if ($row['Username'] == $Username && $row['title'] == $title_checked && $row['description'] == $desc_checked && $row['price'] == $price) { $verbage = '<span class="problemMessage">Product has NOT been saved. You already have this product in your database.</span>'; } else { if (strlen($title_checked) > 20 || strlen($desc_checked) > 30) { $leng = '<span class="problemMessage">Please check the length of your Title and Description. Title is 20 Characters Max and Description is 30 Characters Max.</span>'; } elseif (strlen($title_checked) <= 20 && strlen($desc_checked) <= 30) { mysql_query("INSERT INTO products (Username, title, description, price) VALUES ('$Username','$title_checked','$desc_checked','$price')") or die(mysql_error()); $verbage = '<span class="goodMessage">Your product has been saved.</span>'; } } else { $verbage = '<span class="problemMessage">Product has NOT been Saved. Please enable Javascript & be sure to fill in all fields</span>'; } } } Quote Link to comment https://forums.phpfreaks.com/topic/64600-waht-is-wrong-with-this-line-of-code/#findComment-322090 Share on other sites More sharing options...
ballhogjoni Posted August 13, 2007 Author Share Posted August 13, 2007 Ya I still can't figure it out either. Here is the latest code <?php session_start(); include('db.php'); include('functions.php'); checkLogin('1 2'); $query = mysql_query("SELECT * FROM users WHERE ID = '{$_SESSION['user_id']}'"); $row = mysql_fetch_array($query) or die(mysql_error()); $Username = $row['Username']; if (isset($_POST['submit'])) { if (isset($_POST['title']) && isset($_POST['desc']) && isset($_POST['price'])) { $title_checked = strip_tags($_POST['title']); $desc_checked = strip_tags($_POST['desc']); $price = $_POST['price']; if (!empty($title_checked) && !empty($desc_checked) && !empty($price)) { $query = "SELECT * FROM products WHERE Username = '$Username'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result)); if ($row['Username'] == $Username && $row['title'] == $title_checked && $row['description'] == $desc_checked && $row['price'] == $price) { $verbage = '<span class="problemMessage">Product has NOT been saved. You already have this product in your database.</span>'; } elseif ($row['Username'] != $Username || $row['title'] != $title_checked || $row['description'] != $desc_checked || $row['price'] != $price) { if (strlen($title_checked) > 20 || strlen($desc_checked) > 30) { $leng = '<span class="problemMessage">Please check the length of your Title and Description. Title is 20 Characters Max and Description is 30 Characters Max.</span>'; } elseif (strlen($title_checked) <= 20 && strlen($desc_checked) <= 30) { mysql_query("INSERT INTO products (Username, title, description, price) VALUES ('$Username','$title_checked','$desc_checked','$price')") or die(mysql_error()); $verbage = '<span class="goodMessage">Your product has been saved.</span>'; } } } else { $verbage = '<span class="problemMessage">Product has NOT been Saved. Please enable Javascript & be sure to fill in all fields</span>'; } } else { $verbage = '<span class="problemMessage">Product has NOT been Saved. Please enable Javascript & be sure to fill in all fields</span>'; } } ?> I think its the logic because nothing shows up when I view the page not even the form. (the form is not in the code above) Quote Link to comment https://forums.phpfreaks.com/topic/64600-waht-is-wrong-with-this-line-of-code/#findComment-322109 Share on other sites More sharing options...
ballhogjoni Posted August 13, 2007 Author Share Posted August 13, 2007 Can someone help out with this? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/64600-waht-is-wrong-with-this-line-of-code/#findComment-322326 Share on other sites More sharing options...
MadTechie Posted August 13, 2007 Share Posted August 13, 2007 have you tried print_r($_POST); at the start to help with debugging ? Quote Link to comment https://forums.phpfreaks.com/topic/64600-waht-is-wrong-with-this-line-of-code/#findComment-322333 Share on other sites More sharing options...
jitesh Posted August 13, 2007 Share Posted August 13, 2007 if (($row['Username'] == $Username) && ($row['title'] == $title_checked) && ($row['description'] == $desc_checked) && ($row['price'] == $price)) { Quote Link to comment https://forums.phpfreaks.com/topic/64600-waht-is-wrong-with-this-line-of-code/#findComment-322336 Share on other sites More sharing options...
sasa Posted August 13, 2007 Share Posted August 13, 2007 you don'i echo anything, add echo $verbage; Quote Link to comment https://forums.phpfreaks.com/topic/64600-waht-is-wrong-with-this-line-of-code/#findComment-322387 Share on other sites More sharing options...
ballhogjoni Posted August 13, 2007 Author Share Posted August 13, 2007 have you tried print_r($_POST); at the start to help with debugging ? I did and it printed Array() Quote Link to comment https://forums.phpfreaks.com/topic/64600-waht-is-wrong-with-this-line-of-code/#findComment-322707 Share on other sites More sharing options...
ballhogjoni Posted August 13, 2007 Author Share Posted August 13, 2007 if (($row['Username'] == $Username) && ($row['title'] == $title_checked) && ($row['description'] == $desc_checked) && ($row['price'] == $price)) { Ya i tried that too it still dint work. Thanks for all responses. Quote Link to comment https://forums.phpfreaks.com/topic/64600-waht-is-wrong-with-this-line-of-code/#findComment-322709 Share on other sites More sharing options...
lemmin Posted August 13, 2007 Share Posted August 13, 2007 If it only prints out "Array()", that would mean that your file isn't getting any POST variables, which means the check for, if (isset($_POST['submit'])) , will never be true. Make sure your form is pointing to the right file and using method=POST. Quote Link to comment https://forums.phpfreaks.com/topic/64600-waht-is-wrong-with-this-line-of-code/#findComment-322712 Share on other sites More sharing options...
ballhogjoni Posted August 13, 2007 Author Share Posted August 13, 2007 Right, regardless, the least that the code should do is print the html form because that is not encapsed by php. Example <?php //the code above ?> <html> <head> </head> <body> <!-- my form code --> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/64600-waht-is-wrong-with-this-line-of-code/#findComment-322714 Share on other sites More sharing options...
rlindauer Posted August 13, 2007 Share Posted August 13, 2007 No, you have to submit the form for $_POST to be populated. Quote Link to comment https://forums.phpfreaks.com/topic/64600-waht-is-wrong-with-this-line-of-code/#findComment-322717 Share on other sites More sharing options...
lemmin Posted August 13, 2007 Share Posted August 13, 2007 Sorry, I didn't realize you weren't submitting the form. There are way too many problems that could be occuring before it even gets to the code you posted. You are including two other files before that code. I think what you need to do is split them up and run them individually and see which one gives an error. Quote Link to comment https://forums.phpfreaks.com/topic/64600-waht-is-wrong-with-this-line-of-code/#findComment-322718 Share on other sites More sharing options...
ballhogjoni Posted August 13, 2007 Author Share Posted August 13, 2007 I think its the logic somewhere. Quote Link to comment https://forums.phpfreaks.com/topic/64600-waht-is-wrong-with-this-line-of-code/#findComment-322721 Share on other sites More sharing options...
AndyB Posted August 13, 2007 Share Posted August 13, 2007 I think its the logic somewhere. Could be. I can't help but notice that you go to great lengths to set up a string variable named $leng and another string variable named $verbage and neither of them is ever used in the script, let alone echo'd. What were you expecting other than a blank screen? Quote Link to comment https://forums.phpfreaks.com/topic/64600-waht-is-wrong-with-this-line-of-code/#findComment-322730 Share on other sites More sharing options...
ballhogjoni Posted August 13, 2007 Author Share Posted August 13, 2007 I think its the logic somewhere. Could be. I can't help but notice that you go to great lengths to set up a string variable named $leng and another string variable named $verbage and neither of them is ever used in the script, let alone echo'd. What were you expecting other than a blank screen? LOL thats because I dint post the whole page of code. Here's the form <?php if ($product_count <= 24) { if (isset($verbage)) { echo '<center>'.$verbage.'</center>'; } if (isset($leng)) { echo '<center>'.$leng.'</center>'; } unset($verbage,$leng);?> <form action="" onSubmit="return validateFormOnSubmit(this)" method="POST"> <!--<div align="center" class="formText">This form requires javascript to be enabled</div>--> <table class="standard"> <tr> <td class="formTableLeft">Title:</td> <td class="formTableRight"><input type="text" name="title" /></td> </tr> <tr> <td class="formTableLeft">Description:</td> <td class="formTableRight"><input type="text" name="desc" /></td> </tr> <tr> <td class="formTableLeft">Price:</td> <td class="formTableRight"><input type="text" name="price" /></td> </tr> <tr> <td colspan="2" align="center"><br /><input type="hidden" name="submit" /><input class="formText" type="submit" value="Add Product" /></td> </tr> </table> </form> <?php } else { echo '<span class="problemMessage"><center>You must purchase more product space. Due to the expense we receive for offering this free service, we can only allow 25 free products. <a href="">Click here</a> to purchase more product space.</center></span>'; } Quote Link to comment https://forums.phpfreaks.com/topic/64600-waht-is-wrong-with-this-line-of-code/#findComment-322739 Share on other sites More sharing options...
MadTechie Posted August 13, 2007 Share Posted August 13, 2007 maybe you should post the whole file, half the info doesn't help as much as all of it Quote Link to comment https://forums.phpfreaks.com/topic/64600-waht-is-wrong-with-this-line-of-code/#findComment-322944 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.