/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] One value not working

Hello,

I’m trying to create a form that allows users to add things to the database. Everything is working fine except for one of the input fields, which is causing me trouble. Whenever I edit out $manuf, the rest of the information is added in fine. However, if I try to keep it in I get “Query failed”. I’m completely stumped!

The PHP:

[code=php]
$awpn = $_POST[‘awpn’];
$users = $_POST[‘users’];
$link = $_POST[‘link’];
$manuf = $_POST[‘manuf’];

$qry = “INSERT INTO names(id, AllWorld, Cross) VALUES(‘$users’, ‘<a href=”$link”>$awpn</a>’, ‘$manuf’)”;
$result = @mysql_query($qry);

if($result) {
header(“location: cross-success.php”);
exit();
}else {
die(“Query failed”);
}[/code]

The HTML:

[code=html]<form id=”crossform” name=”crossform” method=”post” action=”cross-exec.php”>
<table width=”500″ border=”0″ cellspacing=”3″ cellpadding=”5″>
<tr>
<td width=”104″>Series:</td>
<td width=”367″>
<input type=”text” name=”awpn” id=”awpn” /></td>
</tr>
<tr>
<td>Manuf. Series:</td>
<td><input name=”manuf” id=”manuf” type=”text” /></td>
</tr>
<tr>
<td>Manuf:</td>
<td><select name=”users”>
<option value=”” selected=”selected”>Select a manufacturer:</option>
<option value=”1″>XXXX</option>
<option value=”2″>XXXY</option>
<option value=”3″>XXYY</option>
</select></td></tr>

<tr>
<td>Link to datasheet:</td>
<td><input name=”link” type=”text” id=”link” size=”50″ value=”http://….” /></td>
</tr>

<tr align=”center” valign=”middle”>
<td colspan=”2″>
<input type=”submit” name=”Submit2″ value=”Cross” />[/code]

Thanks for any help!

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@DerokorianJul 01.2011 — Try echoing the $qry variable when you get the error, for debugging purposes. To see if there is a problem when buiding the query. Also, you can use mysql_error() and mysql_errno() within your die statement to get more information about the error.
Copy linkTweet thisAlerts:
@Andrew977authorJul 05.2011 — Well it turns out one the columns was named "Cross" and that is also a PHP function, so MySQL was becoming confused. Renamed the column and all is well.
Copy linkTweet thisAlerts:
@NogDogJul 05.2011 — Note that you can always quote column/table names with back-tick quotes, just in case they are reserved words SQL terms.
<i>
</i>SELECT <span><code>select</code></span> FROM <span><code>from</code></span> . . .
×

Success!

Help @Andrew977 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.2,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

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