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! Quote Link to comment 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); ?> Quote Link to comment Share on other sites More sharing options...
pacome Posted April 28, 2007 Author Share Posted April 28, 2007 ;D EXCELLENT! THANK YOU! Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.