/    Sign up×
Community /Pin to ProfileBookmark

need help with a query

After I submit an order in my order form, I have my order form set to then call another php script called, “orderform.php” to process an order and automatically send the order to MySQL. However, when I test it out, I keep getting an error that I can’t query.

Any toughts. Here is my orderform.php code:

[CODE]
<!DOCTYPE html>
<head><title>PoemScribe Order Form</title>
</head>
<body>
<h2>PoemScribe</h2>

<?php

$first_name = $_POST[‘firstname’];
$last_name = $_POST[‘lastname’];
$email = $_POST[’email’];
$select_poem_type = $_POST[‘selectpoemtype’];
$key_names = $_POST[‘keynames’];
$specific_words = $_POST[‘specificwords’];
$poem_is_for = $_POST[‘poemisfor’];
$relationship = $_POST[‘relationship’];
$occasion = $_POST[‘occasion’];
$over_all_message = $_POST[‘overallmessage’];
$anything_else = $_POST[‘anythingelse’];

$dbc = mysqli_connect(‘localhost’, ‘login’, ‘password’, ‘database’)
or die(‘Error connecting to MySQL server.’);

$query = “INSERT INTO tuxandp1_poem_orders (first_name, last_name, email, select_poem_type, key_names, specific_words, poem_is_for, ” .
“relationship, occasion, over_all_message, anything_else,) ” .

“VALUES (‘$first_name’, ‘$last_name’, ‘$email’, ‘$select_poem_type’, ‘$key_names’, ‘$specific_words’, ‘$poem_is_for’, ” .
“‘$relationship’, ‘$occasion’, ‘$over_all_message’, ‘$anything_else’)”;

$result = mysqli_query($dbc, $query)
or die (‘Error querying database.’);

mysqli_close($dbc);
?>
</body>
</html>
[/CODE]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NatdripAug 22.2011 — can you post the error and the rendered SQL?
Copy linkTweet thisAlerts:
@OctoberWindAug 23.2011 — $query = "INSERT INTO tuxandp1_poem_orders (first_name, last_name, email, select_poem_type, key_names, specific_words, poem_is_for, " .

"relationship, occasion, over_all_message, anything_else[color=red][B],[/B][/color])[/QUOTE]


hanging comma?
Copy linkTweet thisAlerts:
@salmanshafiqAug 23.2011 — there is a comma placed at the end of fields one.... Please remove that so It will be working fine..........
×

Success!

Help @tuxandpucks 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...