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!";
?>

Link to comment
Share on other sites

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!";
?>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

<?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!";
?>

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.