Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. This $del = DB::getInstance()->query("SELECT * FROM guestbook"); if(!$del->count()) { echo 'No image found'; } else { foreach($del->results() as $del) { unlink($del->path); } } Will delete all the files that are recorded in the database. You'll need to run the following query to delete a file associated with a specific post. $get = DB::getInstance()->get('guestbook', array('id', '=', 132)); // get the guestbook entry that matches id 132 unlink($get->path); // delete the file associated with it
  2. $category['item'] will contain a sub array, either offer or product. You need to loop through this sub array to get the products info Try foreach ($json_arr['categories'] as $categories) { foreach($categories['category'] as $category) { echo "<b> Link </b>" .$category['categoryURL'] ,"<br/>"; foreach($category['item'] as $item) { // get the sub array key $key = key($item); echo "<p><b> Name </b> " .implode(',', $item[$key]['name']), " <br> manufacturer </b>",$item[$key]['manufacturer'] ,"<p>"; // get item description, // for offer use description key // for product use fullDescription key echo "<p><b>Description</b> " . (($key == 'offer') ? $item[$key]['description'] : $item[$key]['fullDescription']) . '</p>'; // display product images echo '<p><b>Images: </b>'; foreach($item[$key]['imageList']['image'] as $image) { echo '<img src="'.$image['SourceUrl'].'" /> '; } echo '</p> // the store logo and name echo '<p><b>Store: </b> <img src="'$item[key]['store']['logo']['sourceURL']'" /> ' .$item[key]['store']['name'] .'</p>'; echo '<hr />'; } } }
  3. upload.php receives the file the user has uploaded from the $_FILES['images'] array. You are then storing the file path for the uploaded file in the 'path' column in your database, along with their name, message and post date $data = DB::getInstance()->insert('guestbook', array( 'name' => $user->data()->username, 'path' => $location, 'message' => Input::get('message'), 'posted' => date('Y-m-d H:i:s') )); This is the only time $_FILE['images'] will exist. When you go to delete.php, you are not uploading a file. Instead you are deleting a record from the database, along with deleting the users uploaded file. To know which file to delete you need fetch the record from the database where the username column matches $user->data()->username (see note below). So you can retrieve the file path for the file they have uploaded. You'd then pass that file path to unlink to remove the users uploaded file. NOTE: Finding the record by username will only work if the user can only add one entry to the guestbook. If they can post multiple entries then you'll need to pass in the id for the guestbook post instead.
  4. Change return response; to $('.response').html(response); Now add <div class="response"></div> in your page where you want the response to be displayed.
  5. Why not use str_getcsv? $string = 'Crossover Crop Top In Burgundy, Burgundy'; list($title, $other) = str_getcsv($string); echo 'Text before comma: ' . $title. '<br />'; echo 'Text after comma: '. $other;
  6. substr($x, strpos($x,',')) will return what is after the comma, if you want to get the text before the comma use substr($x, 0, strpos($x,','))
  7. Not Apache you want to configure, but PHP. You need to open php.ini and set error_reporting to E_ALL and set display_errors to ON. Make sure you restart apache after any changes to the php.ini
  8. wrap everything in div <div id="container"> your page html </div> Now apply a width and auto margins #container { width: 80%; /* webpage width */ margin: 0 auto; /* auto margins, center the content in the middle of the screen */ } Live demo http://jsfiddle.net/cy73q/
  9. Shouldn't you be using $_POST['price']? I do not see an amount field in your form. $amount = $_POST['amount'];
  10. The $_FILES['image'] array will only exist when the file has been uploaded to upload.php. That variable will not be available in delete.php. You will first need to get the users file from the database, and then pass their file path to unlink to delete that file
  11. You could also do it on just one file, just send the action you want to perform in the query string, then use switch/case state to decide what to do switch($_GET['action']) { case 'start'; // start the process break; case 'progress': // return progress of process break; }
  12. Here you are only checking to see if the users credit balance is not zero or less $query = "SELECT SUM(amount) FROM transactions WHERE user_id = {$_SESSION['user_id']}"; if ($result = mysql_query($query)) { $row = mysql_fetch_row($result); if ($row[0] <= 0) { echo "You either have no remaining credits or not enough to complete this transaction. You will be redirected to purchase more."; header( "Refresh:5; url=purchase.php", true, 303); exit(); } } } You are not checking to see if the user has enough credits to perform the transaction. For example the above code could return to say the user only has 1 credit left. But the item they are purchasing costs 2 credits. Your code will complete the transaction, leaving the user in negative credits. To prevent this you need take away the total item cost from their current credit balance, and then check to see if they have enough credits remaining. Eg if ($row[0] - $itemCost <= 0)
  13. You'd pass the id in the url: like you do with a hyperlink 'url': 'post.php?id=id-here', If your id is in javacript variable then use 'url': 'post.php?id=' + your_js_id_variable,
  14. Use success: instead of complete:
  15. This is not a PHP problem. What you want to look at are examples of HTML/CSS multi-level drop down menus. CSSPlay.com has many examples of these, why not take a look their demos and try and implement the one you like into your HTML/CSS.
  16. Rather echo out the the <select>/</option> tags assign them to a variable $engineerList = '<select name="owner[]">'; // Open your drop down box while ($row_engineer = mysql_fetch_array($result_engineer)) { $engineerList .= '<option value>'.$row_engineer['organization'].', '.$row_engineer['l_name'].', '.$row_engineer['f_name'].'</option>'; } $engineerList .= '</select>';// Close your drop down box Now place $engineerList in the $form_block string where you want the select menu to appear. Example $form_block=" <FORM METHOD=\"POST\"ACTION=\"do_add_design_XXXXXX.php\"> ... <P>Engineer: $engineerList</P> <!-- add engineer list --> ... </FORM>";
  17. Any reason you're storing it both on the file system and the database? But to answer your question you need to apply mysql_real_escape_string to $dataBB before using it in your query. EDIT Just noticed you're using mysqli, use mysqli_real_escape_string instead.
  18. use the query trq suggested You'd loop through all the results of a query using a while loop, example $result = $mysqli->query( the select query ); // query db // loop through results while($row = $result->fetch_assoc()) { // now do something with $row['email'] in here } You'd run an update query, // now run an update query on your table, setting sent to 1 $mysqli->query( the update query ); You'd use the exact same WHERE clause used in the SELECT query for the UPDATE query.
  19. Seems like someone is trying to find an vulnerability in you code to perform SQL Injection. mysqli_real_escape_string is what is helping to prevent such attacks. A better aproach would be to use mysqli prepared statements Currently you are allowing any input for the username, including nothing at all. This is because you are not validating the username. if you want to only allow letters, numbers, underscores and hyphens then use the following regex if(preg_match('~[^\w-]+~i', $username)) { echo 'You have invalid characters in your username. Please only use letters, numbers, underscores or hypens'; } Not sure on linux sockets. But the first thing I think of is to make sure that MySQL is running, and your mysql credentials are correct. That is because there isn't a mysqli_exit() function. Maybe you meant to use mysqli_close You are saving the error message to the $_SESSION and then redirecting to site.com/join/. You will have to echo $_SESSION['ERROR1'] to display the error on that page.
  20. Where should the link go to? The correct syntax would be to wrap an achor tag around $row['topicdescription] echo '<p> <b>'.$row['topictitle'].'</b> <a href="link/location.php">'.$row['topicdescription']}.'</a></p>'; Change link/location.php to what you are linking to.
  21. The is because the / at the beginning of a path has a different meanings in PHP and HTML. In HTML it means the root of the url. Whereas with PHP it means the root of the file path (think of it as C:/ for windows). If you want to include a file from the document root. Then use include $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php';
  22. You need to check the quantity after you have taken 1 away. if (isset ($_GET["index"])) { $item_id = $_GET["index"]; // make sure key exists if(isset($_SESSION["viks_cart_array"][$item_id ])) { // now take one away from quantity $_SESSION["viks_cart_array"][$item_id ]['quantity'] -= 1; // check quantity if its zero or less if ($_SESSION["viks_cart_array"][$item_id]["quantity"] <= 0){ unset($_SESSION["viks_cart_array"][$item_id ]); // remove } header("location:" . $_SERVER["PHP_SELF"]); exit; } else { // item doesn't exist // display or log error here } };
  23. What do you mean by this? if you installed Apache and PHP from Ubuntu's package manager then everything should be setup and ready to go. No extra config on Apache/PHP's part is necessary. The only thing you may need to do is add your ubuntu username to the www-data group so you can add/edit/remove files from /var/www
  24. Pyshco array structure is the way to go, as you can immediatly look up the items quantiy using its id as the key to $_SESSION["viks_cart_array"]. Rather then looping over each item one by one checking for items id matches. But working with your current array structure, this will remove the item from the array if the items quantity becomes 0 or less //remove one quantity from item if (isset ($_GET["remove"])) { $x = $_GET["remove"]; foreach($_SESSION["viks_cart_array"] as $index => &$item) { if ($item['item_id'] == $x) { // take 1 away from the qantity $item['quantity'] -= 1; // if item quantity 0 or less if($item['quantity'] <= 0) unset($_SESSION["viks_cart_array"][$index]); // remove current item from array break; } } header("location:" . $_SERVER["PHP_SELF"]); exit; };
  25. Your contact form is being submit via AJAX using Jquery.post(). Using header() in your PHP script wont redirect the user. You need to edit /js/drn.js to perform the redirect. The code for submitting the form is on line 131 of drn.js, try change it to $.post(formAction, formData, function(data) { window.location.replace('/cebucallcenter/thankyou.html'); // redirect user });
×
×
  • 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.