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());
  12. Cool! I will try file_get_contents(). That sounds like the way to go! Thanks to all! - Steve
  13. I am being told that php 5 has additional security when using the include function.. I ran some tests and found that I can only reference parameters that are in the same directory as the file that uses the include, but if I use absolute addressing, it doesn’t work. Here's the code: <?php include('logo.php'); ?> This works <?php include('http://long-island-real-estate-agency.com/HomesForSale/homes-frame.htm'); ?> This doesn't work How can I use include to reference external URLs? Thanks - Steve
  14. [!--quoteo(post=387123:date=Jun 23 2006, 07:42 AM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 23 2006, 07:42 AM) [snapback]387123[/snapback][/div][div class=\'quotemain\'][!--quotec--] Is there any reason why you can't change that - at least for testing purposes - so that it provides truly useful information? Something like this: [code]$query = " ... whatever your query is ..."; $result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query); // useful message[/code] [/quote] I subsutituted in the format you gave and got a more specific error response. It turns out I had a syntax error. Not noticable in the query, but I realized I was going right into this url, forgetting that the variable was set in a cookie in a previous page. If you don't access that page first (which is what I have it designed to do when the users login, then when I run the update query in the next page, it wouldn't be able to assign the variable to the field. Now, it works. Thanks for that. If you wouldn't mind and set me on the right course using the NOW() function as you mentioned before, I would like to change to using this, because I see that the date is more humanly legible, however, I am not sure how to properly syntax it? Any help would be greatly appreciated! Thanks - Steve
  15. [!--quoteo(post=386864:date=Jun 22 2006, 11:50 AM:name=Wildbug)--][div class=\'quotetop\']QUOTE(Wildbug @ Jun 22 2006, 11:50 AM) [snapback]386864[/snapback][/div][div class=\'quotemain\'][!--quotec--] That looks like it should have worked. (At least that format works for me in MySQL client when I just checked it.) Are you quoting the date when you insert it? (You should.) If you just want the current date/time, you can use MySQL's function [b]NOW()[/b]. Can you give us an idea of what error(s) you're getting or what your SQL looks like? [/quote] Thanks for the responses. The error is programmer generated using the die() function. I just have it saying "Cannot update table". I like the idea of using the MySQL NOW() function, but I'm having problems with the correct syntax. I poked around the Internet for how to use this funciton and it only served to get me more confused? [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /]
×
×
  • 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.