Jump to content

websteve

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

websteve's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. It does write to the database, so the problem seems to be when the program reads it back from the db. Here is the code: while ($ResultsArr_pur = mysql_fetch_array($Results_pur)) { $item='item'.$i; $description='description'.$i; $quantity='quantity'.$i; $price='price'.$i; $date='date'.$i; $ampm='ampm'.$i;; $comments='comments'.$i; $status='status'.$i; echo "<tr><td><input type=text size=5 name=".$item ." value=".$ResultsArr_pur['Item']."></td><td><input type=text size=35 name=".$description ." value=".$ResultsArr_pur['Description']."></td><td><input type=text size=5 name=".$quantity ." value=".$ResultsArr_pur['Quantity']."></td><td><input type=text size=10 name=".$price ." value=".$ResultsArr_pur['Price']."></td><td>$".$ResultsArr_pur['Price'] * $ResultsArr_pur['Quantity']."</td><td><input type=text name=".$date ." value=". $ResultsArr_pur['Date'] . "></td><td><select name=".$ampm ."><option>" . $ResultsArr_pur['AMPM'] . "</option><option>AM</option><option>PM</option></select></td><td><input type=text name=".$comments ."size=35 value=". $ResultsArr_pur['Comments'] ."></td><td><select name=".$status . "><option>Undelivered</option><option>Delivered</option>".$ResultsArr_pur['Status']."</option></select></td></tr>"; $i=$i+1; $n=$n+1; }
  2. I have some data that when I type in a string in a text box, (e.g. John Smith), the data is trunctated when it is inserted into the database (only 'John; would show up). I noticed that it seems to cut the data off after a white space. If I combine the words, then they are inserted properly. Does this sound like something simple I'm missing or is it something more complex? The text size is 20 and the db field is Varchar 30. Any help would be appreciated. Thanks.
  3. I can't get this syntax right. Every way I do it, it ends up putting zeros in the database. Can someone help me with the right syntax for concatenating variables within an Update statement? Here's the most recent code I've tried: for ($n=0; $n<=num_rows; $n++) { $pur_update = "UPDATE Purchasing SET Item='$item.$n', Description='$description.$n', Quantity='$quantity.$n', Price='$price.$n', Status='$status.$n', Comments='$comments.$n' WHERE Status = 'Undelivered' AND ID = '" . mysql_real_escape_string($cust_id) . "'"; mysql_query($pur_update)or die('Could not update Purchasing table Or there is nothing to update: ' . mysql_error()); }
  4. Thanks for the reply, but what if I want to display the converted data to the screen? I'm trying this code (below) that searches all rows between 2 dates, using STR_TO_DATE(). Doesn't seem to work correctly, but besides getting this to work right, the end result I want is to echo the converted date to the display. Sorry for sounding confused, I used to work in PHP a few years ago and am just starting to get back into it. This is the code I have now. I know it is not correct. $datefilter = '%m/%d/%y/'; $Res_pur = "SELECT * FROM Purchasing WHERE Date BETWEEN STR_TO_DATE('$beg_date', '$datefilter') AND STR_TO_DATE('$end_date', '$datefilter')"; $Results_pur = mysql_query($Res_pur)or die('Could Not Access Purchasing Table: ' . mysql_error()); while ($Results_pur_Arr = mysql_fetch_array($Results_pur)) { echo '<tr><td>'. $Results_pur_Arr['ID'] . '</td><td>'. $Results_pur_Arr['Date'].'</td><td>'. $Results_Arr['Item'].'</td><td>'.$Results_Arr['Description'].'</td></tr>'; }
  5. Can someone tell me how to convert a MySQL date such as 2010-08-13 into the the US format, such as 8/13/2010, and also the reverse using PHP? I can't seem to find the right functions. Thanks!
  6. Thanks. I googled data_format for additional info and I can figure it out from here. If I have any additional questions, I'll resend a message; otherwise, looks good. Thanks!
  7. I have this Insert statement that converts the US date to the MySQL standand date format: $pur="INSERT INTO Purchasing(ID, Item, Description, Quantity, Price, Date, AMPM) VALUES ('$cust_id','$item_a','$description_a','$quantity1','$price1',STR_TO_DATE('$date', '$datefilter'),'$ampm')"; $datefilter = '%m/%d/%y'; and the $date variable is received from a HTML form and it works fine. But now, I'm trying to figure out how to do it in reverse, such as if I was to Select the date from the database and display it on the screen in US format? I can't seem to find the correct function. Any help would be appreciated. Thanks!
  8. Nope and I am using mysql_error(). I was told I might need to add the mysql_real_escape_string() to prevent injection attacks for Insert. Is that true? And if so, how would I incorporate it into the syntax? Thanks.
  9. I am having a problem with SQL Insert. All of them work, except the last one (highlighted). If anyone has any idea what is going on, please let me know. Thanks. Code is below: $gen="INSERT INTO general (ID, fname, lname, address, city, state) VALUES ('$cust_id','$fname','$lname','$address','$city','$state')"; mysql_query($gen) or die('Could not connect to general table: ' . mysql_error()); $pur="INSERT INTO Purchasing (ID, Item, Description, Quantity, Price) VALUES ('$cust_id','$item','$descr','$quantity','$price')"; mysql_query($pur)or die('Could not connect to Purchasing table: ' . mysql_error()); $cre="INSERT INTO Credit (ID, Credit_Card_Number, Expiration, Code) VALUES ('$cust_id','$credit_card_number','$expiration','$code')"; mysql_query($cre)or die('Could not connect to Credit table: ' . mysql_error()); $del="INSERT INTO Delivery (ID, Date, Time, AMPM) VALUES ('$cust_id','$date','$time','$ampm')"; mysql_query($del)or die('Could not connect to Delivery table: ' . mysql_error());
  10. OK, that makes sense. Thanks. What about this part: $credit_update = "UPDATE Credit SET Credit_Card_Number='$credit_card_number', The credit card number sometimes is updated and sometimes it doesn't take. Any ideas? - Steve
  11. I am trying to update a table, but I am getting intermittent errors. If I run the program and change the credit card number, for example, sometimes it works and other times it doesn't. Also, if I change the expiration to say, 11/12, it returns some type of decimal sequence. The expiration column is set for Varchar. I verified that the variables are being sent through. If anyone can tell me what I am doing wrong, I would appreciate it. Here's the code: $credit_update = "UPDATE Credit SET Credit_Card_Number='$credit_card_number', Expiration=$expiration WHERE ID = '" . mysql_real_escape_string($cust_id) . "'"; mysql_query($credit_update) or die('Could not connect to credit table: ' . mysql_error());
×
×
  • 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.