Jump to content

mdmartiny

Members
  • Posts

    188
  • Joined

  • Last visited

Everything posted by mdmartiny

  1. I get no error messages in my console when I run the script. I actually went into the script and manually put in the id of the item I am trying to delete and it worked. Then when I try and do it dynamically it did not and keeps on doing what it has been doing all along. Here is the code that I am using for the delete page <?php require_once("../../includes/config.php"); $sql = mysqli_query($db, "SELECT `sender`, `reciever` FROM `conversations` WHERE `conversationID` = '". (int)$_POST['id']."'"); $check_sender_reciever = mysqli_fetch_assoc($sql); if ($check_sender_reciever['sender'] == $session_user_id) { $delete = mysqli_query($db,"UPDATE `conversations` SET `sdelete` = '1' WHERE (`conversationID` = '". (int)$_POST['id']."' OR parent='". (int)$_POST['id']."')"); } else if ($check_sender_reciever['reciever'] == $session_user_id) { $delete = mysqli_query($db,"UPDATE `conversations` SET `rdelete` = '1' WHERE (`conversationID` = '". (int)$_POST['id']."' OR parent='". (int)$_POST['id']."')"); } if ($delete === true) { $_SESSION['success'] = 'Message has been successfully deleted!'; } else { $_SESSION['error'] = "Error description: " . mysqli_error($db); } ?>
  2. Hello Everyone, I am trying to send an id to a second page to delete a row from a mysql table. When the button is clicked it shows on the page that the row has been deleted but when the page is refreshed. The item that was supposed to be deleted has returned and it is still in the database. I made a JSfiddle for this http://jsfiddle.net/mikedmartiny/2DKNh/ I would appreciate any help
  3. I am trying to add a contact form to a page. i can't get the script to do anything. When I click on the submit button all it does is sit there no error messages or anything. If the fields are not filled in then there is supposed to be an error message. If everything is ok then there is supposed to be a success message. This is the Jquery code that I am using <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script> <script language="javascript" type="text/javascript" > $(function(){ $("#ContactForm").submit(function(){ $("#submitf").value='Please wait...'; $.post("/contact.php?send=comments", $("#ContactForm").serialize(), function(data){ if(data.frm_check == 'error'){ $("#message_post").html("<div class='errorMessage'>ERROR: " + data.msg + "!</div>"); document.ContactForm.submitf.value='Resend >>'; document.ContactForm.submitf.disabled=false; } else { $("#message_post").html("<div class='successMessage'>Your message has been sent successfully!</div>"); $("#submitf").value='Send >>'; } }, "json"); return false; }); }); </script> Here is the contact page that I am also using <?php $adminemail = "mail@example.com"; if ($_GET['send'] == 'comments'){ $_uname = $_POST['name']; $_uemail = $_POST['email']; $_comments = stripslashes($_POST['message']); $email_check = ''; $return_arr = array(); if($_uname=="" || $_uemail=="" || $_comments==""){ $return_arr["frm_check"] = 'error'; $return_arr["msg"] = "Please fill in all required fields!"; } else if(filter_var($_uemail, FILTER_VALIDATE_EMAIL)) { $to = $adminemail; $from = $_uemail; $subject = "New Contact Us Message: " .$_title; $message = $_comments; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "Content-Transfer-Encoding: 7bit\r\n"; $headers .= "From: " . $from . "\r\n"; @mail($to, $subject, $message, $headers); } else { $return_arr["frm_check"] = 'error'; $return_arr["msg"] = "Please enter a valid email address!"; } echo json_encode($return_arr); } ?> This is my form textpop-upexpan <form action='' method='post' name='ContactForm' id='ContactForm' > <fieldset class="info_fieldset"> <input class="textbox" type="text" name="name" value="" placeholder="Name" /><br /> <input class="textbox" type="text" name="email" value="" placeholder="you@email.com" /><br /> <textarea class="textbox2" name="comments" rows="5" cols="25" placeholder="You can say Hi !"></textarea> <input type='submit' value='Submit' class='myinputbtn' name='submitf' id="submitf"> <div id='message_post'></div> </fieldset> </form> I am trying to learn how to use Jquery so I am not sure what I have going on here or if I am even doing it right.
  4. Yea I am going to start working on the mobile version of the site. I am trying to learn more about responsive web design.
  5. Hello everyone, I have gone through and redid the entire site. I would appreciate it if you guys would let me know what you think of this new design and make sure that everything works. Properly on it. I am still in the process of coding it for Firefox.
  6. file_delete($original); function file_delete($file){ $ftp_server = "xxxxxxx.xxxxx.xxx"; $ftp_user = "xxxxxxx"; $ftp_pass = "xxxxxxx"; $conn_id = ftp_connect($ftp_server) or die("Could not connect to".$ftp_server); $login_result = ftp_login($conn_id, $ftp_user, $ftp_pass); ftp_chdir($conn_id, "/public_html/db_images/ad_images"); ftp_delete($conn_id, $file); ftp_close($conn_id); } I got it to work after some more tinkering around with it... I was not changing directories because I was adding a slash at the end when there should of been none. I fixed the other error by placing the name of the file to be deleted into a different variable.
  7. I have a test directory... this ias where I write scripts and test things out before I put it on the live server. When I was testing out the ftp_delete function. Everything worked. Deleted the files with no issues no errors or anything. When I moved the actual script into the user file. This is when the trouble began and I started getting the errors. That I have posted above. The files are in the appropriate directories and they are there. I have checked them every time I have tried deleting the files and they are still there. What I am trying to figure out is. Why doesn't it work when the test folder and the user folder are on the same directory tree level. When I get home from work tonight I will take a snapshot of my directories and everything for a better description.
  8. That is what I do not understand. I have a test folder on my server where I tryout things before I let them go live. That script works perfectly in there no issues. But when I put the script in this file. I get error messages. So could it be something with the folders?
  9. I am getting this error message now Warning: ftp_chdir() [function.ftp-chdir]: Can't change directory to /home/a6512617/public_html/db_images/ad_images/: No such file or directory in /home/a6512617/public_html/user/modify-ad.php on line 106 The file is there and the folder structure is there.
  10. This is the exact path that I am using ftp_chdir($conn_id, "/public_html/db_images/ad_images/"); Doing what you suggested @scootstah gave me this /home/a6512617/public_html
  11. if (in_array($file_ext, $required_image_ext) == false && (!empty($file_ext))) { $errors[] = "<p>Improper format - Images must be in <strong>GIF</strong>, <strong>PNG</strong>, <strong>JPG</strong>, <strong>JPEG</strong> format.</p>"; } if($file_size > $max_size){ $errors[] = "<p>The image file size is to large. It must be less than <strong>500mb</strong></p>"; } file_delete($delete_image); $move_result = move_uploaded_file($file_tmp, $path_and_name); ak_img_resize($path_and_name, $new_path_name, 300, 250, $file_ext); if(!$move_result){ $errors[] = "<p>There was an error uploading the image</p>"; } The above snippet has where I am trying to use the code. I am trying to access my images directory which is /public_html/db_images/ad_images/
  12. I have been working on this issue for about 2 days or so now. I created a test file in a directory called test_folder ftp-test.php function file_delete($delete_file){ $ftp_server = "xxxxxxx.xxxxx.xxx"; $ftp_user = "xxxxxxx"; $ftp_pass = "xxxxxxx"; $conn_id = ftp_connect($ftp_server) or die("Could not connect to".$ftp_server); $login_result = ftp_login($conn_id, $ftp_user, $ftp_pass); ftp_chdir($conn_id, "/path/to/directory"); ftp_delete($conn_id, $delete_file); ftp_close($conn_id); } $file = "1357458942-01-06-2013.jpg"; file_delete($file); When I run the test file from the test directory it deletes the image. However when I run the same script on the modify page. I keep getting these errors [indent=1][b]Warning[/b][color=#333333][font=Helvetica Neue', Arial, 'Liberation Sans', FreeSans, sans-serif][size=3]: ftp_chdir() [[/size][/font][/color][url="http://bwrummage.vacau.com/user/bwrummage.vacau.com%20/function.ftp-chdir"]function.ftp-chdir[/url][color=#333333][font=Helvetica Neue', Arial, 'Liberation Sans', FreeSans, sans-serif][size=3]]: Can't change directory to /home/a6512617/public_html/db_images/ad_images/: No such file or directory in [/size][/font][/color][b]/home/a6512617/public_html/admin/includes/core/function/general.php[/b][color=#333333][font=Helvetica Neue', Arial, 'Liberation Sans', FreeSans, sans-serif][size=3] on line [/size][/font][/color][b]145[/b][/indent] [indent=1][b]Warning[/b][color=#333333][font=Helvetica Neue', Arial, 'Liberation Sans', FreeSans, sans-serif][size=3]: ftp_delete() [[/size][/font][/color][url="http://bwrummage.vacau.com/user/bwrummage.vacau.com%20/function.ftp-delete"]function.ftp-delete[/url][color=#333333][font=Helvetica Neue', Arial, 'Liberation Sans', FreeSans, sans-serif][size=3]]: Could not delete 1357458942-01-06-2013.jpg : No such file or directory in[/size][/font][/color][b]/home/a6512617/public_html/admin/includes/core/function/general.php[/b][color=#333333][font=Helvetica Neue', Arial, 'Liberation Sans', FreeSans, sans-serif][size=3] on line [/size][/font][/color][b]146[/b][/indent] This is the page that i am trying to use it on [code=php:0]<?php include('../admin/includes/core/init.php'); include('../admin/includes/head.php'); include('../admin/includes/header.php'); include('includes/u-navigation.php'); //This page is located in the user/includes/ directory protect_page(); ?> <script language="Javascript" type="text/javascript" src="/js/jquery.js"></script> <script language="Javascript" type="text/javascript" src="/js/jquery.chainedSelects.js"></script> <script language="Javascript" type="text/javascript" src="/js/jquery.preimage.js"></script> <script language="Javascript" type="text/javascript"> $(function(){ $('#category').chainSelect('#sub-category','/js/combobox.php', { before:function (target) //before request hide the target combobox and display the loading message { $("#loading").css("display","block"); $(target).css("display","none"); }, after:function (target) //after request show the target combobox and hide the loading message { $("#loading").css("display","none"); $(target).css("display","inline"); } }); }); $(function(){ $("#new_image").css("display","none"); $("#delete_image").click(function(){ if ($("#delete_image").is(":checked")){ $("#new_image").show(600); } else { $("#new_image").hide(600); } }); }); $(document).ready(function(){ $('.file').preimage(); }); </script> <style> #loading{ margin-left: auto; margin-right: auto; display:none; } .prev_container{ overflow: auto; width: 300px; height: 135px; } .prev_thumb{ margin: 10px; height: 100px; } </style> <div id="content" class="container_16 clearfix"> <div class="grid_12"> <div class="box"> <?php if($_REQUEST['confirm'] == "Modify Ad" && empty($errors) === true){ $ad = $_POST['ad-id']; $new_cat = $_POST['category']; $new_sub_cat = $_POST['sub-category']; $new_title = sanitize($_POST['title']); $new_price = sanitize($_POST['price']); $new_description = sanitize($_POST['description']); $delete_image = $_POST['delete_image']; $original = $_POST['old-image']; if(!empty($delete_image)){ $max_size = 524288000; $required_image_ext = array('jpg', 'jpeg', 'gif', 'png'); $file_name = $_FILES["file"]["name"]; $file_ext = (explode(".", $file_name)); $file_ext = strtolower(end($file_ext)); $file_size = $_FILES["file"]["size"]; $file_tmp = $_FILES["file"]["tmp_name"]; $path_and_name = "../db_images/ad_images/".$file_name; $new_name = time()."-".date("m-d-Y").".".$file_ext; $new_path_name = "../db_images/ad_images/".$new_name; if (in_array($file_ext, $required_image_ext) == false && (!empty($file_ext))) { $errors[] = "<p>Improper format - Images must be in <strong>GIF</strong>, <strong>PNG</strong>, <strong>JPG</strong>, <strong>JPEG</strong> format.</p>"; } if($file_size > $max_size){ $errors[] = "<p>The image file size is to large. It must be less than <strong>500mb</strong></p>"; } file_delete($delete_image); [b][size=5][color=#FF0000]<------------ HERE[/color][/size][/b] $move_result = move_uploaded_file($file_tmp, $path_and_name); ak_img_resize($path_and_name, $new_path_name, 300, 250, $file_ext); if(!$move_result){ $errors[] = "<p>There was an error uploading the image</p>"; } } if(!empty($new_name)){ mysql_query("UPDATE `ads` SET `cat_id` = '".$new_cat."', `sub_cat_id` = '".$new_sub_cat."', `title`='".$new_title."', `price`='".$new_price."', `description`='".$new_description."', WHERE `ad_id`='".$ad."'"); } else { mysql_query("UPDATE `ads` SET `cat_id` = '".$new_cat."', `sub_cat_id` = '".$new_sub_cat."', `title`='".$new_title."', `price`='".$new_price."', `description`='".$new_description."', `image` = '".$new_name."' WHERE `ad_id`='".$ad."'"); } echo"<h2>Your Ad has been Modified</h2> <form id='select_form' action='/user/modify-ad.php' enctype='multipart/form-data' method='post'> <p> <label>New Category:</label> <select id='category' name='category' > <option value='-----'>-----</option>"; $sql_cat= mysql_query("SELECT `cat_id`, `c_name` FROM category"); while ($row = mysql_fetch_array($sql_cat)) { if ($new_cat == $row['cat_id']) { echo '<option value="' . $row['cat_id'] . '" selected="selected">' . $row['c_name'] . '</option>'; } else { echo '<option value="' . $row['cat_id'] . '">' . $row['c_name'] . '</option>'; } } echo"</select> </p> <p> <label>New Subcategory:</label> <select name='sub-category' id='sub-category' >"; $sql_sub= mysql_query("SELECT `sub_id`, `sub_cat_name` FROM sub_category WHERE `cat_id` = '".$new_cat."'"); while ($row = mysql_fetch_array($sql_sub)) { if ($new_sub_cat == $row['sub_id']) { echo '<option value="' . $row['sub_id'] . '" selected="selected">' . $row['sub_cat_name'] . '</option>'; } else { echo '<option value="' . $row['sub_id'] . '">' . $row['sub_cat_name'] . '</option>'; } } echo "</select> </p> <p> <label>New Title</label> <input type='text' name='title' id='title' value=".$new_title." \/> </p> <p> <label>New Price</label> <input type='text' name='price' id='price' value=".$new_price." \/> </p> <p> <label>New Description</label> <textarea name='description' id='description' >".$new_description."</textarea> </p>"; if(empty($delete_image)){ echo"<p> <label for ='image'>New Image</label> <img src='/db_images/ad_images/".$original."' /> </p>"; } else { echo "<p> <label for ='image'>New Image</label> <img src='/db_images/ad_images/".$new_name."' /> </p>"; } echo "</form>"; } else if($_REQUEST['confirm'] == "Cancel" && empty($errors) === true){ header('Location: /user/edit.php'); exit(); } else { $ad = mysql_query("SELECT * FROM `ads` WHERE `ad_id` = '".$_GET['ad']."'"); $row = mysql_fetch_assoc($ad); //ad variables $cat = $row['cat_id']; $sub = $row['sub_cat_id']; $title = stripslashes($row['title']); $price = $row['price']; $description = $row['description']; $image = $row['image']; ?> <h2>Modify your Ad</h2> <form id="select_form" action="/user/modify-ad.php" enctype="multipart/form-data" method="post"> <input type='hidden' name='ad-id' id='ad-id' value="<?php echo $_GET['ad'] ?>" /><br /> <input type='hidden' name='old-image' id='old-image' value="<?php echo $image ?>" /><br /> <p> <label>Change category:</label> <select id="category" name="category" > <option value="-----">-----</option> <?php $sql_cat= mysql_query("SELECT `cat_id`, `c_name` FROM category"); while ($row = mysql_fetch_array($sql_cat)) { if ($cat == $row['cat_id']) { echo '<option value="' . $row['cat_id'] . '" selected="selected">' . $row['c_name'] . '</option>'; } else { echo '<option value="' . $row['cat_id'] . '">' . $row['c_name'] . '</option>'; } } ?> </select> </p> <p> <label>Change Subcategory:</label> <select name="sub-category" id="sub-category" > <?php $sql_sub= mysql_query("SELECT `sub_id`, `sub_cat_name` FROM sub_category WHERE `cat_id` = '".$cat."'"); while ($row = mysql_fetch_array($sql_sub)) { if ($sub == $row['sub_id']) { echo '<option value="' . $row['sub_id'] . '" selected="selected">' . $row['sub_cat_name'] . '</option>'; } else { echo '<option value="' . $row['sub_id'] . '">' . $row['sub_cat_name'] . '</option>'; } } ?> </select> <span id="loading"><img src="/user/images/ajax-loader1.gif" ></span> </p> <p> <label>Title</label> <input type="text" name="title" id="title" value="<?php echo $title; ?>" /> </p> <p> <label>Price</label> <input type="text" name="price" id="price" value="<?php echo $price; ?>" /> </p> <p> <label>Description</label> <textarea name="description" id="description" ><?php echo $description; ?></textarea> </p> <p> <label for ="image">Image</label> <img src="/db_images/ad_images/<?php echo $image ?>" /> <label for-"Delete Image">Delete Image</label><input name="delete_image" type="checkbox" id="delete_image" value="<? echo $image; ?> "/> </p> <p id="new_image"> <label for ="image">New Image</label> <input class="file" name="file" id="file" type='file' /><div id="prev_file"></div> </p> <input type='submit' name='confirm' value='Modify Ad'> <input type='submit' name='confirm' value='Cancel'> </form> <?php } ?> </div> </div> </div> <?php include('../admin/includes/footer.php'); ?> [/code] the test directory and the user directory(which is where the modify-ad.php is located) are both on the same level in my directory tree. Any help on this matter would be appreciated. I am sure that it is something small that I am over looking
  13. Hello everyone how are you all doing? I am still getting used to the new site layout but I am loving it. OK here is my problem, I am trying to get a chained select box thing going on with a form that is on my site. However, I can not get it to work when I pick the category all the second one does is sit there saying wait on it. So I am hoping that someone on here can help me figure it out. I do believe that the problem lies in the jquery code that is at the bottom of the add-ad.php page. I am not sure since I am not a expert or really know anything about Jquery. I am trying to learn as I go along creating this site. So if anyone could help me that would be great. This is my add-ad.php page <?php include('../admin/includes/core/init.php'); include('../admin/includes/head.php'); include('../admin/includes/header.php'); include('includes/u-navigation.php'); //This page is located in the user/includes/ directory include('includes/select.class.php'); ?> <div id="content" class="container_16 clearfix"> <div class="grid_12"> <div class="box"> <h2>Add an Ad</h2> <form id="select_form"> <p> <label>Choose a category:</label> <select id="category"> <?php echo $opt->ShowCategory(); ?> </select> </p> <p> <label>Choose a sub category:</label> <select id="type"> <option value="0">choose...</option> </select> </p> <p> <label>Title</label> <input type="text" name="title" id="title" /> </p> <p> <label>Price</label> <input type="text" name="price" id="price" /> </p> <p> <label>Description</label> <textarea name="descriptiom" id="description" ></textarea> </p> <p> <label for ="image">Image</label> <input type="file" name="image" id="image" /> </p> <input type="submit" value="Add Ad" /> </form> <div id="result"></div> </div> </div> </div> <?php include('../admin/includes/footer.php'); ?> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("select#type").attr("disabled","disabled"); $("select#category").change(function(){ $("select#type").attr("disabled","disabled"); $("select#type").html("<option>wait...</option>"); var id = $("select#category option:selected").attr('value'); $.post("select_type.php", {id:id}, function(data){ $("select#type").removeAttr("disabled"); $("select#type").html(data); }); }); $("form#select_form").submit(function(){ var cat = $("select#category option:selected").attr('value'); var type = $("select#type option:selected").attr('value'); if(cat>0 && type>0) { var result = $("select#type option:selected").html(); $("#result").html('your choice: '+result); } else { $("#result").html("you must choose two options!"); } return false; }); }); </script> This is my select.class.php page <?php class SelectList { protected $conn; public function __construct() { $this->DbConnect(); } protected function DbConnect() { include "../admin/includes/core/database/connect.php"; $this->conn = mysql_connect($host,$username,$dbpassword) OR die("Unable to connect to the database"); mysql_select_db($dbname,$this->conn) OR die("can not select the database $dbname"); return TRUE; } public function ShowCategory() { $sql = "SELECT * FROM category"; $res = mysql_query($sql,$this->conn); $category = '<option value="0">choose...</option>'; while($row = mysql_fetch_array($res)) { $category .= '<option value="' . $row['cat_id'] . '">' . $row['c_name'] . '</option>'; } return $category; } public function ShowType() { $sql = "SELECT * FROM `sub_category` WHERE `cat_id` = '".$_POST[id]."'"; $res = mysql_query($sql,$this->conn); $type = '<option value="0">'.$_POST['id'].'/option>'; while($row = mysql_fetch_array($res)) { $type .= '<option value="' . $row['sub_id'] . '">' . $row['sub_cat_name'] . '</option>'; } return $type; } } $opt = new SelectList(); ?> This is the select_type.php page <?php include('includes/select.class.php'); echo $opt->ShowType(); ?>
  14. I am in the process of setting up my database that I am going to be using on a website that I am creating. I want to make sure that I am doing it the best way possible. Here are the layouts of my tables The ads table - ad_id primary - user_id unique - cat_id unique - sub_id unique - price - date_created The ad_detail table - detail_id primary - user_id unique - color - size - description The category table - cat_id primary - c_name - c_image The sub category table - sub_id primary - cat_id unique - sub_cat_name - sub_cat_image The users table - user_id primary - f_name - l_name - user_level - email - username - password - secret_question - question_answer - phone - contact - trade_location - date_joined Does this look like it would be a good structure for a database? If not, what changes should I make.
  15. So the general information that all of the ads will contain be in the ads table and then all of the secondary information specific to the particular ad be placed in the details table. Is that correct?
  16. The more I think about it. It would be kind of hardtop do one table. Different ads are going to require different information. A ad for a car is not going to use the same information as an ad for a chair. Do you have a suggestion for a different way of me to store the information used in my ads. I am just trying to figure out the best way to do it. I just don't want to make the ads to general.
  17. Or actually would it be better to have all ads in one table. So I would have these as tables -users -category -sub category -ads Then I could use the Ids from category and sub category as foreign keys in the ads table. That way I only have to search one table instead of like 50 or however many I end up with. I think I originally was going to go with this but thought it would be easier to understand if I had a table for every sub category.
  18. I would also look into making a mobile version of the site. I looked at it from my phone and it was kind of a pain to read everything. Had to shrink my screen to read everything without having to scroll left and right.
  19. I don't really want to search all of the tables. There are going to be some like users, categories and sub categories. The ones that I want to search are going to be the ones that users post their items they are selling in. Which will be a lot I am not sure how many different sub categories that I am going to have I am still working on them.
  20. I have a database that has many tables in it. I would like to do a search of all of the databases. I am unsure on how I would do this. Anyone know a way or point me in the right direction. I am looking to search the tables by date and post the top 10 results.
  21. I am in the process of changing the layout. I am going to use the 960 grid system on it. The design aspect of web development is the weakest part for me. I am trying to learn and together a better eye when it comes to that stuff. Hopefully I will have a new layout by the beginning of next year. Since this is something that I work on in my spare time.
  22. I have been trying to figure this out for days... I want to search all of the tables in a database. Specifically I want to search them by date and get the last 15 that have been entered. I have tried several different ways and none of them work. Does anyone have any idea on how I would do this? Know of a good tutorial that will show me how to do this? Thank you for your help
  23. Yea someone had deleted the test account. I made a new test account username is demo and password is password
  24. I ask for that stuff because I am trying to get input about how people browse and if there is any issue with certain browsers stuff like that. Where were the 404 errors? I will work on the links and try to make it easier for them to be read. Why the page went blank I have no idea.. I just tried and it worked fine for me. Thank you for your feedback and your input.
×
×
  • 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.