// Replace this
if(isset($_POST['submitButton']))
// With this
if(!empty($_POST))
// Then check for values/forms. Some IE versions don't send the submit button
Quote:
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
Sorry i know this is noob stuff.. but i'm in the learning phase here
I have:
Code:
$tagval = $_POST['tagval'];
$cpmval = $_POST['cpmval'];
if (!mysql_connect($db_host, $db_user, $db_pwd))
die("Can't connect to database");
if (!mysql_select_db($database))
die("Can't select database");
$sql = mysql_query("DELETE FROM {$table} WHERE tag = $tagval AND cpm > $cpmval" );
if (!$sql) {
die(mysql_error());
}
it's erroring.. says: "unknown collumn 'steven' in where clause.
the tagval i'm sending is "steven-slist" so it's obviously coming from there somehow..
I thought this was because $tag was being sent, $tag was being retried by POST and then tag was the name of the collumn.. so i changed that variable to $tagval and it's still the same..
Last edited by stevenryals; 11-12-2012 at 03:55 PM..
Reason: because my first response was dumb lol
Sorry i know this is noob stuff.. but i'm in the learning phase here
I have:
Code:
$tagval = $_POST['tagval'];
$cpmval = $_POST['cpmval'];
if (!mysql_connect($db_host, $db_user, $db_pwd))
die("Can't connect to database");
if (!mysql_select_db($database))
die("Can't select database");
$tagval = mysql_real_escape_string($tagval);
$cpmval = mysql_real_escape_string($cpmval);
$sql = mysql_query("DELETE FROM {$table} WHERE tag = $tagval AND cpm > $cpmval" );
if (!$sql) {
die(mysql_error());
}
it's erroring.. says: "unknown collumn 'steven' in where clause.
the tagval i'm sending is "steven-slist" so it's obviously coming from there somehow..
I thought this was because $tag was being sent, $tag was being retried by POST and then tag was the name of the collumn.. so i changed that variable to $tagval and it's still the same..
Notice my amendments in bold. Try that and see how it goes.
It's important, for security, to use that function every single time you put user input into an SQL query.
// Replace this
if(isset($_POST['submitButton']))
// With this
if(!empty($_POST))
// Then check for values/forms. Some IE versions don't send the submit button
Quote:
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND cpm >' at line 1
none of that looks bad to me.. unless for some reason the 2nd variable isnt being populated..
in that case, i switched cpm > $cpmval and the tag = $tagval
the error is the same..
hmmmm.....
Last edited by stevenryals; 11-12-2012 at 04:37 PM..
// Replace this
if(isset($_POST['submitButton']))
// With this
if(!empty($_POST))
// Then check for values/forms. Some IE versions don't send the submit button
Quote:
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
Can't see the error on my phone, but make sure the form input names match up to the POST array keys
They do.. here's the error in text:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND cpm >' at line 1
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND cpm >' at line 1
// Replace this
if(isset($_POST['submitButton']))
// With this
if(!empty($_POST))
// Then check for values/forms. Some IE versions don't send the submit button
Quote:
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
// Replace this
if(isset($_POST['submitButton']))
// With this
if(!empty($_POST))
// Then check for values/forms. Some IE versions don't send the submit button
Quote:
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
form is sending: cval and tval
my action file:
Code:
$tval = mysql_real_escape_string($tval);
$cval = mysql_real_escape_string($cval);
$sql = mysql_query("DELETE FROM expedia WHERE `tag`='$tval' AND `cpm`=$cval" );
if (!$sql) {
die(mysql_error());
}
my current submit form:
Code:
form method=post action="purgestrikesearch.php">
<label>Delete Records: Tag Name:</label>
<input size=15 type=text id=tval name=tval>
<label> Where CPM is greater than:</label>
<input size=2 type=text id=cval name=cval>
<input type=submit value="Delete"></b>
Is that your entire "action file"? Have you made sure you've updated to $_POST['tval'] and $_POST['cval']? Also, wrap your input tag attributes in HTML. You should always do that. <input size="15" type="text" id="tval" name="tval"/>.
If that still doesn't solve anything, at the top of your "action file" (after <?php obviously) put var_dump($_POST); and post here what comes out, as well as your complete "action file".
// Replace this
if(isset($_POST['submitButton']))
// With this
if(!empty($_POST))
// Then check for values/forms. Some IE versions don't send the submit button
Quote:
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.