/    Sign up×
Community /Pin to ProfileBookmark

MySQL Input not working

I am using the MySQL Input statement, but I keep getting the [B]unexpected T-String[/B] error. I am assuming it is a syntax error, but I can’t seem to find where the problem is, or maybe it is something more. It’s been a while since I worked with SQL, so any help would be appreciated.

Here’s the code:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
<html xmlns=”http://www.w3.org/1999/xhtml“>
<head>
<title>Untitled Document</title>
</head>

<body>
<?PHP

$cust_id = $_POST[“cust_id”]; $item = $_POST[“item”]; $description = $_POST[“description”]; $quantity = $_POST[“quantity”]; $price = $_POST[“price”]; $comments = $_POST[“comments”];

$link = mysql_connect(“localhost”, “rr_steve”, “eg555”) or die (“Access To DB Error”);
mysql_select_db(“rr_test”, $link) or die (“DB not selected”);

$pur = “INSERT INTO Purchasing (‘ID’, ‘Item’, ‘Description’, ‘Quantity’, ‘Price’, ‘Comments’) VALUES ($cust_id, $item, $description, $quantity, $price, $comments);”
mysql_query($pur);
?>

</body>
</html>

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJul 03.2010 — No terminal semi-colon on the preceding line. (You have it within the quoted string literal.)
Copy linkTweet thisAlerts:
@MindzaiJul 04.2010 — Also note that your code is open to SQL injection attacks. You also want quotes around the string variables in your SQL query or else it will fail.
Copy linkTweet thisAlerts:
@webphotogeekauthorJul 04.2010 — I knew it was some simple stuff to fix. Thank you both!
×

Success!

Help @webphotogeek spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...