pacome Posted April 28, 2007 Share Posted April 28, 2007 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 More sharing options...
taith Posted April 28, 2007 Share Posted April 28, 2007 <?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 More sharing options...
pacome Posted April 28, 2007 Author Share Posted April 28, 2007 ;D EXCELLENT! THANK YOU! Link to comment https://forums.phpfreaks.com/topic/49097-insert-variable-in-db/#findComment-240545 Share on other sites More sharing options...
taith Posted April 28, 2007 Share Posted April 28, 2007 no prob... just needed to change this... insertar($IBE, $tipo) so you could access the variables through the function Link to comment https://forums.phpfreaks.com/topic/49097-insert-variable-in-db/#findComment-240549 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.