Script php che non va più' con Versione MySQL: 5.6

  • Creatore Discussione Creatore Discussione Trapano
  • Data di inizio Data di inizio

Trapano

Utente Attivo
27 Set 2012
238
0
16
49
Ciao.
Ho questo script che nel vecchio spazio web, funziona, ma spostandolo su un nuovo spazio che ha
Versione MySQL: 5.6... visualizza questo errore: Incorrect integer value: '' for column 'id' at row 1
lo script è questo:
PHP:
<?php
include 'datidb.php';
include 'conf.php';
session_start();
if ($_SESSION['username']==$usern);
else{
header('Location: login.htm');
}{ ?>

<head>
<title>INSERIMENTO PROMEMORIA</title>
<style type="text/css">
<!--
a:link {text-decoration: none;}
-->
</style>
</head>

<body style="text-align: center;" text='black' alink="black" lang="IT" link="black" vlink="black" MARGINHEIGHT="0" bgcolor='white'>

<table align='center' border='0' width='100%' cellpadding='0' cellspacing='0'>
<tr>
<td align='left' width='33%'>
<b><a href='elenco.php'><input style='color:black;background-color:WHITE;font-size:25' type="submit" value='<-- ELENCO'></a></b>
</td>
<td align='center' width='33%'>
<font color='black' size='8'><a href='elenco.php'><?php echo $time=date('Y-m-d');?></a></font></td>
<td align='right' width='33%'></td>
</tr>
</table><br>

<?php
$data_oggi = date('Y-m-d');
$ora_oggi = date('H:i');
$link = mysql_connect($DB_host, $DB_user, $DB_password);
if (!$link)
{
    die ('Non riesco a connettermi: ' . mysql_error());
}
$db_selected = mysql_select_db($DB_name, $link);
if (!$db_selected)
{
    die ("Errore nella selezione del database: " . mysql_error());
}
$reg = $_GET['reg'];
if ( $reg == 1 )
{

$id = $_POST['id'];
$valore = $_POST['valore'];
$data = $_POST['data'];
$ora = $_POST['ora'];

mysql_query("INSERT INTO promemoria
(id,valore,data,ora)
VALUES
('$id','$valore','$data','$ora')")
            
OR DIE(mysql_error());
$result = mysql_query ("SELECT * FROM PROMEMORIA");
$num=mysql_numrows($result);
while($row = mysql_fetch_array( $result ))
{
    $id=$row['id'];       
} 

echo "<font size='8' color='red'>-- PROMEMORIA INSERITO! --</font><br><br>";
 echo "<meta http-equiv='refresh' content='1;url=elenco.php' />";

}
?>

<form action='inserimento.php?reg=1' method='POST' onSubmit="return formCheck(this)">

<table align='center' bgcolor='' border='0' width='100%' cellpadding='1' cellspacing='1'>
<td align='center'>

<textarea style='color:black;background-color:white;font-size:40;' name="valore" rows="4" cols="40">
</textarea><br>

<input style='color:black;background-color:white;font-size:50;' type='date' name='data' size='10' value='<?php echo $data_oggi ;?>'>
<input style='color:black;background-color:white;font-size:50;' type='time' name='ora' size='10' value='<?php echo $ora_oggi ;?>'><br><br>
<input style='color:black;background-color:yellow;font-size:25;' name="Procedi" type="submit" value="MEMORIZZA"><br>
</td>
</table><br><br>

</form>
<br><br><br><br>

</body>
<?php
}
?>
 
Ultima modifica di un moderatore:
Ciao, prova a togliere gli apici a $id
 
Grazie per la risposta Critic.
Ho tolto tutte le righe che contenevano ip
PHP:
<?php
include 'datidb.php';
include 'conf.php';
session_start();
if ($_SESSION['username']==$usern);
else{
header('Location: login.htm');

}{ ?>

<head>
<title>INSERIMENTO PROMEMORIA</title>
<style type="text/css">
<!--
a:link {text-decoration: none;}
-->
</style>
</head>

<body style="text-align: center;" text='black' alink="black" lang="IT" link="black" vlink="black" MARGINHEIGHT="0" bgcolor='#F8DEE3'>

<table align='center' border='0' width='100%' cellpadding='0' cellspacing='0'>
<tr>
<td align='left' width='25%'>
<b><a href='elencop.php'><input style='color:black;background-color:WHITE;font-size:25' type="submit" value='<-- ELENCO'></a></b>
</td>
<td align='center' width='50%'>
<font color='black' size='6'><a href='elenco.php'>NUOVO PROMEMORIA</a></font></td>
<td align='right' width='25%'></td>
</tr>
</table><br>




<form action='inserimentop.php?reg=1' method='POST' onSubmit='return formCheck(this)'>
<table align='center' bgcolor='' border='0' width='100%' cellpadding='1' cellspacing='1'>
<td align='center'>
<textarea style='color:black;background-color:white;font-size:40;' name='valore' rows='4' cols='40'>
</textarea><br>
<input style='color:black;background-color:white;font-size:50;' type='date' name='data' size='10' value='<?php
echo $data_oggi = date('Y-m-d');
?>'>
<input style='color:black;background-color:white;font-size:50;' type='time' name='ora' size='10' value='<?php
echo $ora_oggi = date('H:i');
?>'><br><br>
<input style='color:black;background-color:yellow;font-size:25;' name='Procedi' type='submit' value='MEMORIZZA'><br>
</td>
</table><br><br>
</form>

<?php
$link = mysql_connect($DB_host, $DB_user, $DB_password);
if (!$link)
{
    die ('Non riesco a connettermi: ' . mysql_error());
}
$db_selected = mysql_select_db($DB_name, $link);
if (!$db_selected)
{
    die ('Errore nella selezione del database: ' . mysql_error());
}
$reg = $_GET['reg'];
if ( $reg == 1 )
{

$valore = $_POST['valore'];
$data = $_POST['data'];
$ora = $_POST['ora'];

mysql_query ("INSERT INTO promemoria (valore,data,ora) VALUES ('$valore','$data','$ora')")
            
OR DIE(mysql_error());
$result = mysql_query ('SELECT * FROM PROMEMORIA');
$num=mysql_numrows($result);
while($row = mysql_fetch_array( $result ))
{
    $id=$row['id'];       
}

echo "<font size='8' color='red'>-- PROMEMORIA INSERITO! --</font><br><br>";
 echo "<meta http-equiv='refresh' content='1;url=elencop.php' />";

}
?>


<hr>
<center><?php
include 'calendario.php';
?>
</center><br><br><br>

</body>
<?php
}
?>

In effetti il db aumenta lo stesso di uno a ogni record inserito e non da più errori.
 
io avevo detto solo gli apici.
ricordati di racchiudere il codice che posti nei tag di formattazione
 
Grazie.
Ma così è sbagliato il mio script?


Provo a mettere un codice
Codice:
<?php
prova
?>
 

Discussioni simili