keski va po dans ce code php ? :_(

keski va po dans ce code php ? :_( - Programmation

Marsh Posté le 13-02-2002 à 08:23:38    

$requete_insertion = "INSERT $machine_new_debit INTO machine_debit";
$resultat_insertion = odbc_exec($connection, $requete_insertion);

Reply

Marsh Posté le 13-02-2002 à 08:23:38   

Reply

Marsh Posté le 13-02-2002 à 08:30:20    

Heu...
 
1) tu met pas de valeur ?
2) si tu nous donnais le source complet (ou en tout cas toute la partie intéressante :)) et le message d'erreur que te renvois MySQL...


---------------
A+++ Bruce - http://www.bheller.com
Reply

Marsh Posté le 13-02-2002 à 08:35:51    

voila msieu :
 
while (odbc_fetch_row($resultat) )
{
$machine_sorties = odbc_result($resultat, 5);
$machine_nom = odbc_result ($resultat, 2);
$machine_debit = odbc_result ($resultat, 3);
$machine_new_debit = $machine_debit * $machine_sorties ;
 
echo "le copieur ", $machine_nom, " qui a un debit de ", $machine_debit, " copies/min, a effectué jusqu'a maintenant: ", $machine_new_debit, " copies." ;
echo "<br>";
 
$requete_insertion = "INSERT $machine_new_debit INTO machine_debit";
$resultat_insertion = odbc_exec($connection, $requete_insertion);
 
}
 
?>
 
et le message d'erreur :
 
Warning: SQL error: [Microsoft][Pilote ODBC Microsoft Access] Erreur de syntaxe dans l'instruction INSERT INTO., SQL state 37000 in SQLExecDirect in c:\program files\easyphp\www\projet\index.php on line 37

Reply

Marsh Posté le 13-02-2002 à 08:39:03    

Bon... heu revois la syntaxe SQL parceque là il y as un gros manque :D
 
Tiens, je t'aide :

Code :
  1. 6.4.2 INSERT Syntax
  2.     INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
  3.         [INTO] tbl_name [(col_name,...)]
  4.         VALUES (expression,...),(...),...
  5. or  INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
  6.         [INTO] tbl_name [(col_name,...)]
  7.         SELECT ...
  8. or  INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
  9.         [INTO] tbl_name
  10.         SET col_name=expression, col_name=expression, ...
  11. INSERT inserts new rows into an existing table. The INSERT ... VALUES form of the statement inserts rows based on explicitly specified values. The INSERT ... SELECT form inserts rows selected from another table or tables. The INSERT ... VALUES form with multiple value lists is supported in MySQL Version 3.22.5 or later. The col_name=expression syntax is supported in MySQL Version 3.22.10 or later.
  12. tbl_name is the table into which rows should be inserted. The column name list or the SET clause indicates which columns the statement specifies values for:
  13. If you specify no column list for INSERT ... VALUES or INSERT ... SELECT, values for all columns must be provided in the VALUES() list or by the SELECT. If you don't know the order of the columns in the table, use DESCRIBE tbl_name to find out.
  14. Any column not explicitly given a value is set to its default value. For example, if you specify a column list that doesn't name all the columns in the table, unnamed columns are set to their default values. Default value assignment is described in section 6.5.3 CREATE TABLE Syntax.
  15. An expression may refer to any column that was set earlier in a value list. For example, you can say this:
  16. mysql> INSERT INTO tbl_name (col1,col2) VALUES(15,col1*2);
  17. But not this:
  18. mysql> INSERT INTO tbl_name (col1,col2) VALUES(col2*2,15);
  19. If you specify the keyword LOW_PRIORITY, execution of the INSERT is delayed until no other clients are reading from the table. In this case the client has to wait until the insert statement is completed, which may take a long time if the table is in heavy use. This is in contrast to INSERT DELAYED, which lets the client continue at once. See section 6.4.3 INSERT DELAYED syntax. Note that LOW_PRIORITY should normally not be used with MyISAM tables as this disables concurrent inserts. See section 7.1 MyISAM Tables.
  20. If you specify the keyword IGNORE in an INSERT with many value rows, any rows that duplicate an existing PRIMARY or UNIQUE key in the table are ignored and are not inserted. If you do not specify IGNORE, the insert is aborted if there is any row that duplicates an existing key value. You can determine with the C API function mysql_info() how many rows were inserted into the table.
  21. If MySQL was configured using the DONT_USE_DEFAULT_FIELDS option, INSERT statements generate an error unless you explicitly specify values for all columns that require a non-NULL value. See section 2.3.3 Typical configure Options.
  22. You can find the value used for an AUTO_INCREMENT column with the mysql_insert_id function. See section 8.4.3.126 mysql_insert_id().
  23. If you use INSERT ... SELECT or an INSERT ... VALUES statement with multiple value lists, you can use the C API function mysql_info() to get information about the query. The format of the information string is shown below:
  24. Records: 100 Duplicates: 0 Warnings: 0
  25. Duplicates indicates the number of rows that couldn't be inserted because they would duplicate some existing unique index value. Warnings indicates the number of attempts to insert column values that were problematic in some way. Warnings can occur under any of the following conditions:
  26. Inserting NULL into a column that has been declared NOT NULL. The column is set to its default value.
  27. Setting a numeric column to a value that lies outside the column's range. The value is clipped to the appropriate endpoint of the range.
  28. Setting a numeric column to a value such as '10.34 a'. The trailing garbage is stripped and the remaining numeric part is inserted. If the value doesn't make sense as a number at all, the column is set to 0.
  29. Inserting a string into a CHAR, VARCHAR, TEXT, or BLOB column that exceeds the column's maximum length. The value is truncated to the column's maximum length.
  30. Inserting a value into a date or time column that is illegal for the column type. The column is set to the appropriate zero value for the type.


---------------
A+++ Bruce - http://www.bheller.com
Reply

Marsh Posté le 13-02-2002 à 08:40:21    

VIVE LE COPIER COLLER

Reply

Marsh Posté le 13-02-2002 à 08:42:30    

t'apo un truc moins....long

Reply

Marsh Posté le 13-02-2002 à 08:43:46    

Bha oui :) Bon, je t'aide dans le INSERT faut lui mettre les valeurs... Et ça se passe APRES le INTO et sous la forme VALUES()...
 
Bref exemple tout con :
 
INSERT INTO table('identifiant','nom';) VALUES (NULL,'toto';);


---------------
A+++ Bruce - http://www.bheller.com
Reply

Marsh Posté le 13-02-2002 à 08:44:53    

angel92 a écrit a écrit :

t'apo un truc moins....long  




 
Heu, tu sais si tu lis jamais la doc tu y arrivera pas... C vrais que le SQL c pas simple au début, j'ai la chance d'avoir apris en cours (put'1 je sais pas si je pigerais les BDD et le SQL sans les cours :)), mais à défaut de cours lire un peu de doc ça fait jamais de mal.


---------------
A+++ Bruce - http://www.bheller.com
Reply

Marsh Posté le 13-02-2002 à 08:45:00    

mouarf

Reply

Marsh Posté le 13-02-2002 à 08:45:56    

oui oui, je lme suis acheter un livre, programmation en php 4 de compupresse, il est bien ce livre, avec kelkes notions de sql

Reply

Marsh Posté le 13-02-2002 à 08:45:56   

Reply

Marsh Posté le 13-02-2002 à 08:46:58    

Heu... bha les bouquins oui si tu veux, mais rien ne vaux la vraie doc officiele (fourni avec MySQL) ou un véritable explicatif des BDD et du SQL... Le php utilise le SQL mais franchement c deux éléments bien différents...


---------------
A+++ Bruce - http://www.bheller.com
Reply

Marsh Posté le 13-02-2002 à 08:49:03    

ouep, jvai m'y mettre, ( c'est pour ca que je commznce a faire des scripts tout seul)

Reply

Marsh Posté le 13-02-2002 à 08:49:51    

Bha bon courrage alors :D


---------------
A+++ Bruce - http://www.bheller.com
Reply

Marsh Posté le 13-02-2002 à 09:16:56    

jvai en avoir besoin

Reply

Marsh Posté le 13-02-2002 à 09:56:46    

je pe po faire ca ?
 
$requete_insertion = "INSERT INTO machine IN machine_debit VALUES $machine_new_debit_journalier";
 
paske je ve inseré la variable (qui aura une valeur): $machine_new_debit dans la table machine et dans la colonne machine_debit .

Reply

Marsh Posté le 13-02-2002 à 10:16:35    

mouarf

Reply

Marsh Posté le 13-02-2002 à 10:31:50    

:heink:

Reply

Marsh Posté le 13-02-2002 à 10:51:47    

Tiens voici un exemple :  
INSERT INTO Store_Information (store_name, Sales, Date)
VALUES ('Los Angeles', 900, 'Jan-10-1999';)  
 
Et dans ton cas:
 
INSERT INTO machine(machine_debit) VALUES('$machine_new_debit_journalier';)
 
je pense que c bon mais si c faux corrigez moi les gars :)
 
Voilà en espérant avoir répondu à ta question
 
@+

 

[jfdsdjhfuetppo]--Message édité par dirakocha--[/jfdsdjhfuetppo]


---------------
Q.G Tutoriaux ici
Reply

Marsh Posté le 13-02-2002 à 10:52:32    

ok, je vais essayer et voir ce que ca donne

Reply

Marsh Posté le 13-02-2002 à 11:04:41    

oups je me suis gouré, le truc en fait c'est qu'il fo que je mette a jour le chiffre, je remplace INSERT par UPDATE ?

Reply

Marsh Posté le 13-02-2002 à 11:23:58    

Ok alors pour l'UPDATE ça fonctionne comme ça :
 
UPDATE "table_name" SET "column_1" = [new value]  
WHERE {condition}  
 
Et pour toi:
 
UPDATE machine SET machine_debit = $machine_new_debit_journalier
where machine = 'le nom de la machine'
 
 
Voili voilou
 :hello:


---------------
Q.G Tutoriaux ici
Reply

Marsh Posté le    

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed