Jump to content

[SOLVED] very simple query problem! driving me insane!


unistake

Recommended Posts

Hi,

can someone look at this! Ive done tons of these before and spent over 30mins going over each comma in this code!

Ive double checked all the variables and links. Therefore it must be how ive written it!

Please have a look thanks

 

<?php
@session_start();
if (@$_SESSION['auth'] !="yes")
{
include ("../login.htm");		
exit();
}

extract($_POST); 
include ("../wayla.inc");
$username = $_SESSION['username'];
$query = "INSERT INTO ac_spec (admin, reg, make, model, year, value, avionics, horsepower, mtow, usefulload, fuelcap, fuelgph, cruisingspeed, cruisingrange, tod, ld, intrating, extrating)
    VALUES ('$username', '$reg', '$make', '$model', '$year', '$value', '$avionics', $horsepower', '$mtow', '$usefulload', '$fuelcap', '$fuelgph', '$cruisingspeed', '$cruisingrange', '$tod', '$ld', '$intrating', '$extrating')";
$result = mysqli_query ($cxn,$query)
or die ("cant execute query!");

echo "done!";
?>

Warning: mysqli_error() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\carbheat\TIMMYS\area\acspec_process.php on line 14

 

line 14 is the $result line.

 

<?php
@session_start();
if (@$_SESSION['auth'] !="yes")
{
include ("../login.htm");		
exit();
}

extract($_POST); 
include ("../wayla.inc");
$username = $_SESSION['username'];
$query = "INSERT INTO ac_spec (admin, reg, make, model, year, value, avionics, horsepower, mtow, usefulload, fuelcap, fuelgph, cruisingspeed, cruisingrange, tod, ld, intrating, extrating)
    VALUES ('$username', '$reg', '$make', '$model', '$year', '$value', '$avionics', $horsepower', '$mtow', '$usefulload', '$fuelcap', '$fuelgph', '$cruisingspeed', '$cruisingrange', '$tod', '$ld', '$intrating', '$extrating')";
$result = mysqli_query ($cxn,$query) or die (mysqli_error($cnx));
echo "done!";
?>

Warning: mysqli_error() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\carbheat\TIMMYS\area\acspec_process.php on line 14

 

line 14 is the $result line.

 

<?php
@session_start();
if (@$_SESSION['auth'] !="yes")
{
include ("../login.htm");		
exit();
}

extract($_POST); 
include ("../wayla.inc");
$username = $_SESSION['username'];
$query = "INSERT INTO ac_spec (admin, reg, make, model, year, value, avionics, horsepower, mtow, usefulload, fuelcap, fuelgph, cruisingspeed, cruisingrange, tod, ld, intrating, extrating)
    VALUES ('$username', '$reg', '$make', '$model', '$year', '$value', '$avionics', $horsepower', '$mtow', '$usefulload', '$fuelcap', '$fuelgph', '$cruisingspeed', '$cruisingrange', '$tod', '$ld', '$intrating', '$extrating')";
$result = mysqli_query ($cxn,$query) or die (mysqli_error($cnx));
echo "done!";
?>

 

$cnx obviously isn't a valid connection link then, where do you make the connection?

<?php
@session_start();
   if (@$_SESSION['auth'] !="yes")
   {
   include ("../login.htm");      
   exit();
   }
   
extract($_POST); 
include ("../wayla.inc");
$username = $_SESSION['username'];
$query = "INSERT INTO ac_spec (admin, reg, make, model, year, value, avionics, horsepower, mtow, usefulload, fuelcap, fuelgph, cruisingspeed, cruisingrange, tod, ld, intrating, extrating)
       VALUES ('$username', '$reg', '$make', '$model', '$year', '$value', '$avionics', $horsepower', '$mtow', '$usefulload', '$fuelcap', '$fuelgph', '$cruisingspeed', '$cruisingrange', '$tod', '$ld', '$intrating', '$extrating')";
$result = mysqli_query ($cxn,$query) or die (mysqli_error($cxn));
echo "done!";
?>

another thing

 

$query = "INSERT INTO ac_spec (admin, reg, make, model, year, value, avionics, horsepower, mtow, usefulload, fuelcap, fuelgph, cruisingspeed, cruisingrange, tod, ld, intrating, extrating)
       VALUES ('$username', '$reg', '$make', '$model', '$year', '$value', '$avionics', HERE!!! $horsepower', '$mtow', '$usefulload', '$fuelcap', '$fuelgph', '$cruisingspeed', '$cruisingrange', '$tod', '$ld', '$intrating', '$extrating')";

 

should be

 

$query = "INSERT INTO ac_spec (admin, reg, make, model, year, value, avionics, horsepower, mtow, usefulload, fuelcap, fuelgph, cruisingspeed, cruisingrange, tod, ld, intrating, extrating)
       VALUES ('$username', '$reg', '$make', '$model', '$year', '$value', '$avionics', '$horsepower', '$mtow', '$usefulload', '$fuelcap', '$fuelgph', '$cruisingspeed', '$cruisingrange', '$tod', '$ld', '$intrating', '$extrating')";

 

Thanks for all your instant help guys!

thorpe, howcome the extract($_POST) is dangerous? - I take your word for it but would like to know

 

Because you don't escape any of the incoming data. This meens I could execute sql injections on your database and remove any data, gain access, all sorts of stuff you probably don't want people doing.

Thanks for all your instant help guys!

thorpe, howcome the extract($_POST) is dangerous? - I take your word for it but would like to know

 

anyone can send arbitrary post variables to your script and it would make them PHP variables automatically.

 

I think

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.