Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-12-2012, 08:36 PM   PM User | #16
BluePanther
Senior Coder

 
Join Date: Jul 2011
Posts: 1,226
Thanks: 3
Thanked 171 Times in 171 Posts
BluePanther is on a distinguished road
Why have you dropped the $_POST superglobal variable assignments? That's how the data is passed from the function. Also, the mysql_real_escape_string() should be after a mysql connection.

PHP Code:
<?php

$db_host 
=  <defined>
$db_user =  <defined>
$db_pwd = <defined>
$database = <defined>
$table =<defined>

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");

$tval mysql_real_escape_string($_POST['tval']);
$cval mysql_real_escape_string($_POST['cval']);

$sql mysql_query("DELETE FROM expedia WHERE `tag`='$tval' AND `cpm`=$cval" );
if (!
$sql) {
    die(
mysql_error());
}



mysql_free_result($result);

?>
__________________
Useful function to retrieve difference in times
The best PHP resource
A good PHP FAQ
PLEASE remember to wrap your code in [PHP] tags.
PHP Code:
// 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.
BluePanther is offline   Reply With Quote
Old 11-13-2012, 12:29 AM   PM User | #17
stevenryals
New Coder

 
Join Date: Jul 2012
Posts: 60
Thanks: 4
Thanked 0 Times in 0 Posts
stevenryals is an unknown quantity at this point
ok, i've made those changes.. and am whitescreened... still not working..

see file:

Code:
<?php

$db_host = 
$db_user = 
$db_pwd = 
$database = 
$table = 


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");

$t = mysql_real_escape_string($_POST['tval']);
$c = mysql_real_escape_string($_POST['cval']);
settype($c, 'float');

$sql = mysql_query("DELETE FROM {$table} WHERE `tag` = '$t' AND `cpm` = $c" );

if (!$sql) {
    die(mysql_error());
}
else  {
echo "Well.. They're gone.. for good..";
echo "<BR>";
echo "<a href='pyflightsearchresults.php'>Back to Results</a>";
}


echo "<a href="pyflightsearchresults.php">That's it. They're gone.. you can't get them back.. gone forever...  click here to return to strikesearch results</a>";

mysql_free_result($result);

?>
I have placed vardump on the 2 variables.. and they show good to that point:
Quote:
float(9) string(8) "testing3"
in firebug i see the post values & 500 internal server error

Last edited by stevenryals; 11-13-2012 at 01:27 AM..
stevenryals is offline   Reply With Quote
Old 11-13-2012, 08:07 AM   PM User | #18
BluePanther
Senior Coder

 
Join Date: Jul 2011
Posts: 1,226
Thanks: 3
Thanked 171 Times in 171 Posts
BluePanther is on a distinguished road
if you're getting "white screened", it's usually because the PHP encountered a problem whilst executing, and you don't have error reporting on. Check your error log.
__________________
Useful function to retrieve difference in times
The best PHP resource
A good PHP FAQ
PLEASE remember to wrap your code in [PHP] tags.
PHP Code:
// 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.
BluePanther is offline   Reply With Quote
Old 11-13-2012, 08:11 AM   PM User | #19
BluePanther
Senior Coder

 
Join Date: Jul 2011
Posts: 1,226
Thanks: 3
Thanked 171 Times in 171 Posts
BluePanther is on a distinguished road
Why are you casting $c to a float btw? Also, you shouldn't really mix your coding styles (concerning your two different if styles). In my opinion, curly brackets are ALWAYS the best, so i'd suggest using that for all your if statements.
__________________
Useful function to retrieve difference in times
The best PHP resource
A good PHP FAQ
PLEASE remember to wrap your code in [PHP] tags.
PHP Code:
// 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.
BluePanther is offline   Reply With Quote
Old 11-13-2012, 01:35 PM   PM User | #20
stevenryals
New Coder

 
Join Date: Jul 2012
Posts: 60
Thanks: 4
Thanked 0 Times in 0 Posts
stevenryals is an unknown quantity at this point
Changing $c to float to match the database..
I made the if/else changes as well

It seems to be working.. at the moment, thank god.

I appreciate the help.. sorry to be such a pain..

Thanks again.. hopefully i can keep learning and contribute to others on this forum.
stevenryals is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:38 PM.


Advertisement
Log in to turn off these ads.