Jump to content

Insert Variable in DB


pacome

Recommended Posts

I'm trying to insert into DB but it doesn't

 

any ideas why?

 

 

<?php

 

function insertar ()

 

{

$con = mysql_connect ('','','') or die ("no conn");

@mysql_select_db ('aerosim') or die ("hey somth wrong");

$sql = "INSERT INTO vuelos (`vuelo`,`tipo`) VALUES ('$IBE','$tipo')";

mysql_query ($sql) or die (mysql_error ($con));

}

 

 

 

if ($vuelo = ""){

$vuelo=rand(1000,4000);}

else{

$vuelo = ($vuelo + rand(1000,5000));}

echo "IBE".$vuelo;

$IBE="IBE".$vuelo;

$tipo = "A330";

insertar($IBE, $tipo);

 

?>

an id and timestamp variables are written to the DB each time I refresh the page, but the variables from the script don't get written... so connection is ok, but variables are not getting there...

 

thanks!

Link to comment
https://forums.phpfreaks.com/topic/49097-insert-variable-in-db/
Share on other sites

<?php

function insertar($IBE, $tipo){

$con = mysql_connect ('','','') or die ("no conn");

@mysql_select_db ('aerosim') or die ("hey somth wrong");

$sql = "INSERT INTO vuelos (`vuelo`,`tipo`) VALUES ('$IBE','$tipo')";

mysql_query ($sql) or die (mysql_error ($con));

}

 

if($vuelo = ""){

$vuelo=rand(1000,4000);

}else{

$vuelo = ($vuelo + rand(1000,5000));

}

echo "IBE".$vuelo;

$IBE="IBE".$vuelo;

$tipo = "A330";

insertar($IBE, $tipo);

?>

Link to comment
https://forums.phpfreaks.com/topic/49097-insert-variable-in-db/#findComment-240541
Share on other sites

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.