Jump to content

Barand

Moderators
  • Posts

    24,611
  • Joined

  • Last visited

  • Days Won

    834

Everything posted by Barand

  1. http://uk1.php.net/manual/en/mysqli-stmt.bind-param.php
  2. does this do it? $data = explode("\n", $stream); foreach ($data as $line) { $arr = str_getcsv($line,',', "'"); if ($arr[5] != 'OK') { echo $line.'<br>'; } }
  3. buildSelectOptions() takes 3 arguments, you are passing 4.
  4. The answer is clearly "Yes"
  5. Look again! before: ID: 14 Cover:1 after: ID: 14 Cover:0 Both the image and cover are changed. If your objective is to switch which is the main image, just change cover and not the image name (or vice versa)
  6. if it's in a file, fgetcsv() would be my weapon of choice.
  7. OK, so what you told us in the first post was just a small part of the whole story. Is that "unformatted output" held in a text file?
  8. for($i = 0; $i < count($_POST['option_title']); $i++) { if (trim($_POST['option_title'][$i]) != '' && trim($_POST['option_quantity'][$i]) != '' && trim($_POST['option_retail_price'][$i]) != '' && trim($_POST['option_discount_price'][$i]) != '') { $insert_options->execute(array( $get_item_id, $_POST['option_title'][$i], $_POST['option_quantity'][$i], $_POST['option_retail_price'][$i], $_POST['option_discount_price'][$i] )); } }
  9. Example CREATE TABLE IF NOT EXISTS users_access_log ( log_id INT UNSIGNED NOT NULL AUTO_INCREMENT, user_id INT UNSIGNED NOT NULL, action VARCHAR(50) NOT NULL, previous_data VARCHAR(250) NOT NULL, current_data VARCHAR(250) NOT NULL, changed_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (log_id), KEY (user_id) ); CREATE TRIGGER log_address_change AFTER UPDATE ON user_addresses FOR EACH ROW INSERT INTO users_access_log (user_id,action,previous_data,current_data) VALUES ( NEW.user_id, CASE NEW.address_type WHEN 1 THEN 'Residential change' ELSE 'Postal change' END, CONCAT_WS(', ', OLD.street_no, OLD.street_name, OLD.city), CONCAT_WS(', ', NEW.street_no, NEW.street_name, NEW.city) );
  10. Triggers http://dev.mysql.com/doc/refman/5.6/en/create-trigger.html
  11. try foreach ($xml->Device as $device) { echo (string)$device['clientIdentifier'] . '<br/>'; }
  12. You can't include function calls inside strings as you are doing. You need to split the string in two and concatenate the function call. For example, instead of $message = "<p>Expected Repair Date: date('d/m/Y', strtotime($exrdate))</p>"; you would need $message = "<p>Expected Repair Date: " . date('d/m/Y', strtotime($exrdate)) . "</p>"; Alternatively you could store the results of the function calls in variables and then put those in the string EG $newId = mysqli_insert_id($mysqli); $repairDate = date('d/m/Y', strtotime($exrdate)); $message = "<p>Expected repair date: $repairDate</p> <p>ID: $newId</p>";
  13. Sorry. Check for blanks before inserting postal address
  14. Check the individual values inside the loop, before calling execute()
  15. First two lines should be $header = "Content-Type: text/html;charset=utf-8\r\n"; $header .= "From: [email protected]\r\n" . "Reply-To: [email protected]\r\n";
  16. mysql> SELECT * FROM item_images; +----------------+---------+-------+---------+ | item_images_id | item_id | cover | path | +----------------+---------+-------+---------+ | 1 | 58 | 1 | 111.jpg | | 2 | 58 | 0 | 222.jpg | +----------------+---------+-------+---------+ Then your query (the names have been changed to protect the innocent) UPDATE item_images im1, item_images im2 SET im1.cover = im2.cover, im2.cover = im1.cover, im1.path = im2.path, im2.path = im1.path WHERE im1.item_id = im2.item_id AND im1.path = '222.jpg' AND im2.path = '111.jpg' AND im1.item_id = 58; gives mysql> SELECT * FROM item_images; +----------------+---------+-------+---------+ | item_images_id | item_id | cover | path | +----------------+---------+-------+---------+ | 1 | 58 | 0 | 222.jpg | | 2 | 58 | 1 | 111.jpg | +----------------+---------+-------+---------+ which looks OK to me ???
  17. According to my IDE, the {s at the ends of these three lines have no corresponding closing }s <?php if(isset($_POST['submit'])){ if(isset($_GET['go'])){ if(preg_match("/^[ a-zA-Z]+/", $_POST['search'])){
  18. Would it be asking too much for you to post the error message that you are getting?
  19. I have to admit to being confused about why there is a repairs table with both an auto_inc ID and a unique repairID column. Why are these not the same column?
  20. What happened to the while($row=mysql_fetch_array($result)){ which you had in you previous version? You now have foreach ($result ... ) which is completely wrong
  21. $sql = "INSERT INTO user_addresses (user_id, address_type, street_no, street_name, city) VALUES (?,?,?,?,?) ON DUPLICATE KEY UPDATE street_no = VALUES(street_no), street_name = VALUES(street_name), city = VALUES(city)"; $stmt = $db->prepare($sql); $stmt->bind_param('iisss', $user_id, $address_type, $street_no, $street_name, $city ); // res address $address_type = 1; $stmt->execute(); // postal address $address_type = 2; $street_no = $p_street_no; $street_name = $p_street_name; $city = $p_city; $stmt->execute();
  22. I think you are missing a closing "}" before </table>
  23. No, you have a record for each address so you will need one prepared query, but you will execute it twice, once for the residential address data and again for the postal address data
  24. How would we know from what you have posted? Why do you need the ID. Is the repairID not unique?
  25. Then both will be updated. If a new address is the same as an existing address then MySQL will ignore the update and do nothing.
×
×
  • 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.