Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

[HS] [ASP] Probl?me page d'insertion dans la base

2 réponses
Avatar
de Palmas
Bonjours ? tous,
Je suis vraiment d?sol? de faire ce hors sujet, mais je suis bloqu? depuis
plusieurs semaines avec mon site que je d?vellope en ASP.
J'ai cr?e un formulaire, qui a pour fonction un enregistrement des donn?es
dans la base de donn?e (Access).
Lorsque je teste ma page ( code ci-joint) j'ai un message d'erreur:
Une constante de cha?ne ?tait attendue mais aucun caract?re de guillemet
d'ouverture n'a ?t? trouv?. Erreur de traitement d...

<font face="Arial" size=2>
-------------------------^




--------------------------------------------------------------------------------
---
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/conn_woldairline.asp" -->
<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables

If (CStr(Request("MM_insert")) = "form1") Then

MM_editConnection = MM_conn_woldairline_STRING
MM_editTable = "Horaires"
MM_editRedirectUrl = "admin2.asp"
MM_fieldsStr =
"HoNovol|value|HoJr|value|HoLDep|value|HoLArr|value|HoHrDep|value|HoHrArr|value|
select|value"
MM_columnsStr =
"HoNovol|',none,''|HoJr|',none,''|HoLDep|',none,''|HoLArr|',none,''|HoHrDep|',no
ne,NULL|HoHrArr|',none,NULL|HoApp|',none,''"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")

' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next

' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And
Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If

End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it

Dim MM_tableValues
Dim MM_dbValues

If (CStr(Request("MM_insert")) <> "") Then

' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ")
values (" & MM_dbValues & ")"

If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%>
<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers="Administrateur"
MM_authFailedURL="admin.asp"
MM_grantAccess=false
If Session("MM_Username") <> "" Then
If (false Or CStr(Session("MM_UserAuthorization"))="") Or _
(InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then
MM_grantAccess = true
End If
End If
If Not MM_grantAccess Then
MM_qsChar = "?"
If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
MM_referrer = Request.ServerVariables("URL")
if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" &
Request.QueryString()
MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" &
Server.URLEncode(MM_referrer)
Response.Redirect(MM_authFailedURL)
End If
%>
<%
Dim Ident__MMColParam
Ident__MMColParam = "1"
If (Session("MM_username") <> "") Then
Ident__MMColParam = Session("MM_username")
End If
%>
<%
Dim Ident
Dim Ident_numRows

Set Ident = Server.CreateObject("ADODB.Recordset")
Ident.ActiveConnection = MM_conn_woldairline_STRING
Ident.Source = "SELECT PiNom, PiPr?nom, PiVille, PiDernVol FROM Pilote WHERE
PiCallsing = '" + Replace(Ident__MMColParam, "'", "''") + "'"
Ident.CursorType = 0
Ident.CursorLocation = 2
Ident.LockType = 1
Ident.Open()

Ident_numRows = 0
%>
<%
Dim Horaires
Dim Horaires_numRows

Set Horaires = Server.CreateObject("ADODB.Recordset")
Horaires.ActiveConnection = MM_conn_woldairline_STRING
Horaires.Source = "SELECT * FROM Horaire"
Horaires.CursorType = 0
Horaires.CursorLocation = 2
Horaires.LockType = 1
Horaires.Open()

Horaires_numRows = 0
%>
<%
Dim flotte
Dim flotte_numRows

Set flotte = Server.CreateObject("ADODB.Recordset")
flotte.ActiveConnection = MM_conn_woldairline_STRING
flotte.Source = "SELECT FlAppareil, FlImmat FROM Flotte"
flotte.CursorType = 0
flotte.CursorLocation = 2
flotte.LockType = 1
flotte.Open()

flotte_numRows = 0
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Document sans titre</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script language="JavaScript" type="text/JavaScript">
<!--
<%
Response.Cookies("PiCallsing") = Request.QueryString("PiCallsing")
Response.Cookies("PiCallsing").Expires = date+30
%>

<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if
((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight;
onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH)
location.reload();
}
MM_reloadPage(true);
//-->

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail
address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number
between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n';
}
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>

<body bgcolor="#000099">
<p><i><b><font face="Arial" size="5" color="#FFFFFF"><img border="0"
src="_Images/Logo-VA02.gif" width="205" height="85" align="left" hspace="0"
/></font></b></i> </p>
<p>&nbsp;</p>
<p>&nbsp; </p>
<p>&nbsp; </p>
<div style="position: absolute; width: 785px; height: 354px; z-index: 2; left:
235px; top: 8px; border: 2px solid #000000; background-color: #1841AD"
id="couche3"> <font face="Arial" size="4" color="#FFFFFF">&nbsp; </font>
<form name="form1" id="form1" method="POST" action="<%=MM_editAction%>">
<table width="95%" border="0">
<tr>
<td width="32%"><strong><font color="#999999">Numero de
vol</font></strong></td>
<td width="68%"><input name="HoNovol" type="text" id="HoNovol"
value="WRXXXX" maxlength="6" /></td>
</tr>
<tr>
<td><strong><font color="#999999">Jour</font></strong></td>
<td> <select name="HoJr" id="HoJr">
<option value="Lundi">Lundi</option>
<option value="Mardi">Mardi</option>
<option value="Mercredi">Mercredi</option>
<option value="Jeudi">Jeudi</option>
<option value="Vendredi">Vendredi</option>
<option value="Samedi">Samedi</option>
<option value="Dimanche">Dimanche</option>
</select></td>
</tr>
<tr>
<td><strong><font color="#999999">D&eacute;part</font></strong></td>
<td><input name="HoLDep" type="text" id="H

2 réponses

Avatar
paritel
bonjour,

pourtant l'erreur est indiqu?e :
<font face="Arial" size=2>
-------------------------^
met des guillemets autour du 2 et a mon avis ca va mieux marcher hein dit

bernard
Avatar
Krystyan
je crois qu'il a déjà demandé, et que certains lui ont déjà répondu.
Il a même été aiguillé vers d'autre forum plus adéquate (s'agissant d'une
question portant sur de l'asp, il aura des réponses plus claires sur des ng
traitant d'asp.)
Mais a priori, de Palmas n'a pas dû comprendre les explications.
(voir post du 04/10)
zwetan, phpdirector, estampida lui ont pourtant répondu de manière claire.

le pb peut également venir d'une inclusion, par exemple :
include file="Connections/conn_woldairline.asp
admin2.asp
et en controlant toutes les balises asp ou html, il y en a forcement une qui
n'est pas correctement fermée..

Un petit cours de méthodologie :
- test ton code bout par bout.
- pour chaque ligne de traitement : faire afficher le résultat par un
print/echo

et controle tous les fichiers inclus.

P.S. : si depuis le 04/10 tu n'as toujours pas avancé sur la résolution de
ce pb, soit tu remets en cause le fichier complet, soit ta conception, soit
ta manière de développer et de contrôler des développements mais amha 15
jours sans réussir à débugguer une page asp... rassure-nous tu bosses pas de
manière professionnelle, tu programme en amateur ?

--
Krystyan
Avant de poser une question, lire (et comprendre) ceci :
http://faqmm.free.fr

"paritel" a écrit dans le message de
news:cl2ism$gbg$
bonjour,

pourtant l'erreur est indiqu?e :
<font face="Arial" size=2>
-------------------------^
met des guillemets autour du 2 et a mon avis ca va mieux marcher hein dit

bernard