Jump to content

radagast

Members
  • Posts

    18
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

radagast's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello i am using PDO. I will go over the PDO Prepared Statements again to see where I have gone wrong.
  2. Hello I am still fairly new to the PDO / mysqli thing and I would really appreciate some help with escaping special characters from the below code. $sth = ("SELECT * from table WHERE field1 = '$bob' and field2 != ''"); foreach ($dbh->query($sth) as $row) { $who = $row['field2']; $why = $row['field1']; $dbh1->query("UPDATE table SET who = '$who', date = '$row[DATE]', time = '$row[TIME]' WHERE field1 = '$why'")or die(mysqli_error($db)); } I have tried using the prepared statement as well as the mysqli_real_escape_string but sees the code results as an object. Any help or comments would be greatly appreciated.
  3. Jazzman1 that worked perfectly. Thank you so much for your responds and help really appreciate it.
  4. Good Day Please could someone be so gracious as to help me with the following problem. I am wanting to update a MYSQL database from a Firebird database. I have tested connecting to both databases individually which works fine, it is just when I put the code together it does not work. Below is the code //Firstly I connect to the MYSQL database to see what needs to updated mysql_connect("localhost", "database", "password") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); $check = "SELECT * FROM table WHERE blah != ''"; $result = mysql_query($check) or die ("Error in query: $check. " . mysql_error()); if (mysql_num_rows($result) > 0) { while($row = mysql_fetch_object($result)) { $blah = $row->blah; // Then I connect to the Firebird database to get the info $dsndb = 'host'; $userdb = 'user'; $passdb = 'password'; try { $dbh = new PDO($dsndb, $userdb, $passdb); $sth = ("SELECT * from table WHERE blah = '$blah'"); foreach ($dbh->query($sth) as $row) { //Then I update the MYSQL database from the Firebird database info $sql = "UPDATE table SET field1 = 'field1', field2 = 'field2', field3 = 'field3' WHERE blah = '$blah'"; $update=mysql_query($sql) or die(mysql_error()); } } } } Your assistance will be greatly appreciated.
  5. Thanks very much for the help objnoob
  6. Good Day objnoob Thank you so much for your responds. Yes you are right they have now confirm that it is in fact JSON and I have asked them to make it a single javascript array/object as you suggested and they seem to be more confused than me. They sent me the below code. $arr = array("waybill" => $WAYBILL, "booking_no" => $REFERENCE); $data = array( 'tracking' => array() ); $data['tracking'][ ] = $arr; header('Content-Type: application/json; charset=utf8'); echo json_encode($data); Your help once again will be greatly appreciated.
  7. Hello I am really having a brain freeze an am hoping that someone can help. I will be receiving the below array from our courier every 3 hours and need to update our mysql database. Array Snippet : {"tracking":[{"waybill":"TCG3267158","booking_no":"94887"}]}{"tracking":[{"waybill":"TCG3240376","booking_no":"94870"}]}{"tracking":[{"waybill":"TCG3267284","booking_no":"94664"}]}{"tracking":[{"waybill":"TCG3343222","booking_no":"94892"}]}{"tracking":[{"waybill":"TCG3235404","booking_no":"93326"}]}{"tracking":[{"waybill":"TCG2976343","booking_no":"93547"}]}{"tracking":[{"waybill":"TCG3246653","booking_no":"93357"}]}{"tracking":[{"waybill":"TCG3199956","booking_no":"93517"}]}{"tracking":[{"waybill":"TCG3216882","booking_no":"93449"}]}{"tracking":[{"waybill":"TCG3170110","booking_no":"93879"}]}{"tracking":[{"waybill":"TCG3247064","booking_no":"93807"}]}{"tracking":[{"waybill":"TCG3252060","booking_no":"93439"}]} I am unsure on how to retrieve the data from the array to insert into our database as per the below. $sql = "UPDATE waybill SET waybill = '$waybill' WHERE booking_no = '$booking_no' AND waybill IS NULL"; $update=mysql_query($sql) or die(mysql_error()); All and any help will be greatly appreciated.
  8. Hello MaaSTaaR Yes thanks so much that did the trick
  9. Good Day I am have the following problem and would appreciate any help. I would like to send a email as well as update orders.sent_order_confirm when the below SELECT query criteria is meet $sendemail = "SELECT * FROM orders WHERE order_num IS NOT NULL AND sent_order_confirm IS NULL"; $result = mysql_query($sendemail) or die ("Error in query: $sendemail. " . mysql_error()); // if records present // iterate through resultset // print title with links to edit and delete scripts if (mysql_num_rows($result) > 0) { while($row = mysql_fetch_object($result)) { $order_num = $row->order_num; $email=$row->email; $contactname=$row->dest_contact; $formsentfrom = mail("$email", "Your Online Order Number $order_num", "Good Day $contactname \r\n\r\n This email is just to let you know that your Order Number $order_num has been processed \r\n", "From: orders@online.com"); $sql = "UPDATE orders SET sent_order_confirm = 'yes' WHERE order_num = $order_num"; $result=mysql_query($sql); } } At the moment it is only updating one row and sending one email. But If I remove the below then it will send emails to all rows. $sql = "UPDATE orders SET sent_order_confirm = 'yes' WHERE order_num = $order_num"; $result=mysql_query($sql); So my question is how do I get it to update all rows and send all emails within the loop. All and any help will be greatly appreciated.
  10. Hi Thorpe I really feel like a DUMBASS But a really happy DUMBASS Thanks for taking the time to help and have a GREAT weekend
  11. Hi The problem is that it only updates the last row into the database.
  12. Hi Thorpe Thanks for responding. I tried many different scenarios to retrieve the data from the Firebird Database and the select seems to be the only one to work. If you have another method that will work please let me know. Thanks
  13. Hello I am hoping someone can PLEASSSSSSE help me I am trying to do the following php Script.. //Getting Information for firebird database from supplier/distributor try { $dbh = new PDO($dsndb, $userdb, $passdb); $sth = ("SELECT * from order WHERE account_number = 'abc123'"); foreach ($dbh->query($sth) as $row) // If I do print $row['order_number'].' - '. $row['customer_ref'] . '<br />'; returns all data.. { $row['order_number']; $row['customer_ref']; } } catch (PDOException $e) { echo 'You have the following error : ' . $e->getMessage() . "<br/>"; die(); } $on = $row['order_number']; $ref = $row['customer_ref']; // Need to update MYSQL Database but not sure how to create loop?????? mysql_connect("localhost", "user", "password") or die(mysql_error()); mysql_select_db("xoccoza_online") or die(mysql_error()); $sql = "UPDATE customer SET customer_ref = '$ref' WHERE order_number = '$on' and customer_ref IS NULL"; $result=mysql_query($sql) or die(mysql_error()); Any and all help will be greatly appreciated
  14. Ok I sorted out my problem. Bold and red below is what I added. <script> var sd = new Date(); for(var i = 0; i < 7; i++) { if($.datepicker.noWeekends(sd)[0]) break; //found a valid day, hop out sd.setDate(sd.getDate() + 1); //move to the next day } $(function() { $( "#datepicker" ).datepicker({ beforeShowDay: $.datepicker.noWeekends, defaultDate: sd, minDate: new Date().getHours() >= 16 ? 1 : 0, maxDate: "+1M +10D", altField: "#alternate", altFormat: "DD, d MM, yy" }); }); </script>
  15. Hi I am hoping someone can help me. I have a jquery datepicker which I need to go to the next available day if the time is >16:00. I have the following script which I would like to add the above to. <script> var sd = new Date(); for(var i = 0; i < 7; i++) { if($.datepicker.noWeekends(sd)[0]) break; //found a valid day, hop out sd.setDate(sd.getDate() + 1); //move to the next day } $(function() { $( "#datepicker" ).datepicker({ beforeShowDay: $.datepicker.noWeekends, defaultDate: sd, minDate: 0, maxDate: "+1M +10D", altField: "#alternate", altFormat: "DD, d MM, yy" }); }); </script> Thanks in advance
×
×
  • 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.