Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old January 28th, 2004, 08:05 PM
shoegaze shoegaze is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: sandy eggo
Posts: 14 shoegaze User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Inserting string Values into Table

ok, I'm having trouble getting the following to Parse because the Value for $insert_item is a string that contains commas (,)

Code:
$sql = "INSERT INTO $inv_item (invoicenumber, qty, item) VALUES
('$insert_invoicenumber', '$insert_qty', '$insert_item')";



any suggestions?

Reply With Quote
  #2  
Old January 28th, 2004, 08:18 PM
shoegaze shoegaze is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: sandy eggo
Posts: 14 shoegaze User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Inserting string Values into Table

ok i just went back and did
Code:
mysql_escape_string


but to no effect.. =(

Reply With Quote
  #3  
Old January 28th, 2004, 08:34 PM
CodeKadiya CodeKadiya is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Colombo,Sri Lanka
Posts: 2,313 CodeKadiya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
Send a message via Yahoo to CodeKadiya
RE: Inserting string Values into Table

I don't think comma would be a problem... can you echo your sql statement and check what values are there?
php Code:
Original - php Code
  1.  
  2. $sql = "INSERT INTO $inv_item (invoicenumber, qty, item) VALUES
  3. ('$insert_invoicenumber', '$insert_qty', '$insert_item')";
  4. echo $sql;
what does it output?

Reply With Quote
  #4  
Old January 28th, 2004, 09:11 PM
shoegaze shoegaze is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: sandy eggo
Posts: 14 shoegaze User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Inserting string Values into Table

ok heres the code i have:

Code:
<?

if ( $_POST[add_invoicenumber] and $_POST[add_qty] and $_POST[add_item] )

{


$db_name = "steelskindata";


$connection = @mysql_connect("localhost", "steelskin", "winter")
or die (mysql_error());
$db = @mysql_select_db($db_name, $connection) or
die(mysql_error());


$insert_invoicenumber = $_POST[add_invoicenumber];
$insert_qty = $_POST[add_qty];
$insert_item = "(mysql_escape_string($_POST[add_item]))";


$sql = "INSERT INTO $inv_item (invoicenumber, qty, item) VALUES
('$insert_invoicenumber', '$insert_qty', '$insert_item')";
echo "$sql";

$result = @mysql_query($sql, $connection) or die(mysql_error());


exit;
 
}

?>



and the error i get reads:

INSERT INTO (invoicenumber, qty, item) VALUES ('36', '55', '(mysql_escape_string(18 gauge , 1/4 length , BB , NOTES: ))')You have an error in your SQL syntax near '(invoicenumber, qty, item) VALUES ('36', '55', '(mysql_escape_string(18 gauge , ' at line 1

Reply With Quote
  #5  
Old January 28th, 2004, 09:19 PM
shoegaze shoegaze is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: sandy eggo
Posts: 14 shoegaze User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Inserting string Values into Table

this is the string value for the item:

18 gauge , 1/4 length , BB , NOTES:

i think that slash is doing something...

Reply With Quote
  #6  
Old January 29th, 2004, 12:43 AM
CodeKadiya CodeKadiya is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Colombo,Sri Lanka
Posts: 2,313 CodeKadiya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
Send a message via Yahoo to CodeKadiya
RE: Inserting string Values into Table

Run this code and see...
php Code:
Original - php Code
  1.  
  2. <?
  3. $number = addslashes($_POST['add_invoicenumber']);
  4. $qty = addslashes($_POST['add_qty']);
  5. $item = addslashes($_POST['add_item']);
  6.  
  7. if ($number && $qty && $item)
  8. {
  9.     $db_name = "steelskindata";
  10.     $conn = mysql_connect("localhost", "steelskin", "winter") or die (mysql_error());
  11.     mysql_select_db($db_name, $connn) or die(mysql_error());
  12.    
  13.     $sql = "INSERT INTO $inv_item(invoicenumber,qty,item) VALUES('$number','$qty','$item')";
  14.    
  15.     $result = mysql_query($sql) or die(mysql_error());
  16.  
  17.     exit;   
  18. }
  19. ?>
Let me know if there is any part you cannot understand.. I hope you can!

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Inserting string Values into Table


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT