Uitlezen sql en insert where

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Pagina: « vorige 1 2

Albert de Wit

Albert de Wit

17/11/2012 23:22:18
Quote Anchor link
"Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1"

Dit betekent dat je ergens een error in je query hebt. Dit is geen PHP error, dit is een SQL error. Dus we hoeven alleen maar queries te zien.
 
PHP hulp

PHP hulp

25/04/2024 21:55:59
 
Kevin Zegikniet

Kevin Zegikniet

17/11/2012 23:25:59
Quote Anchor link
Goed in de tabel staat:
ID...Voornaam...Achternaam...Username...etc
.1...[.LEEG.]...[..LEEG..]...Admin
.2...[.LEEG.]...[..LEEG..]...Kevin
.3...[.LEEG.]...[..LEEG..]...(een andere gebruiker)

Meer is er niet (ja password, emailadres en geboortedatum)
maar dit zijn de enige 3 rijen.

Misschien ligt het aan de $row['id'] uit het inlogscript?

Toevoeging op 17/11/2012 23:42:04:

Hey wacht...
Ik ververs ineens mijn phpmyadmin, en tadaa!
het staat er wel in...
 
Albert de Wit

Albert de Wit

17/11/2012 23:42:45
Quote Anchor link
Een query is een interactie met de database die je vanuit PHP verstuurd. Bijvoorbeeld:

SELECT * FROM items
DELETE FROM items WHERE id_item='1'
UPDATE items SET item_naam='item1' WHERE id_item='1'
INSERT INTO items (item_naam) VALUES ('item1')
 
Kevin Zegikniet

Kevin Zegikniet

17/11/2012 23:46:03
Quote Anchor link
Dat snap ik ook. Maar op een of andere manier doet 'ie het wel, en krijg ik dan de error nog een keer.
En het ligt em niet aan error_reporting(e_all) geloof ik.
Maargoed, het werkt iig.

Heb je nu ook nog een manier om de id uit de tabel in een sessie variabele te toveren?
Zie eerste vraag bij mijn eerste post op dit topic.
 
Eddy E

Eddy E

18/11/2012 08:53:05
Quote Anchor link
Voer je de query niet 2x uit of zo?
Want bij een foutmelding mag het ook niet werken...
 
Kevin Zegikniet

Kevin Zegikniet

18/11/2012 12:51:01
Quote Anchor link
Ik heb geen flauw idee.
De query staat er maar 1x in, dus ik zou zeggen van niet.
 
Eddy E

Eddy E

18/11/2012 12:56:53
Quote Anchor link
Geef je code eens...
 
Kevin Zegikniet

Kevin Zegikniet

18/11/2012 12:59:30
Quote Anchor link
volgens mij staat die op de vorige pagina ook, maar hier nog een keer.

Inlogscript: (kweenie of dat helpt, maar dat is het script voorafgaand)
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
session_unset();
session_start();

mysql_connect("localhost", "root", "") or die("Kan niet verbinden met de database: " . mysql_error());
mysql_select_db("datingsite") or die("Kan de database niet vinden: ". mysql_error());
$md5_pass=md5($_POST['password']);

$_SESSION['username']=$_POST[username];

$sql_inlog = mysql_query (
        "SELECT id
        FROM user
        WHERE username = '"
. mysql_real_escape_string($_POST['username']) . "'
        AND password = '"
. ($md5_pass) . "'
        "
);
$_SESSION['id']=$row['id'];
IF($sql_inlog === false)
    {
echo 'Error1: ' . mysql_error(); }
else {
    // Kijk of lijst 1 ingevuld is, zo niet stuur door naar lijst 1
    $sql_l1 = mysql_query (
            "SELECT provincie
            FROM user
            WHERE id = "
. intval($_SESSION['id']) . "
            ORDER BY id"
) ;
    if ($sql_l1 === false)
        {
echo 'Error2: ' . mysql_error(); }
    else {  $info = mysql_fetch_row($sql_l1);
        if ($info[0] == '')
            {
$_POST['controle']="FALSE";
            header('Location: lijst1.php'); }
        else {// Kijk of lijst 2 ingevuld is, zo niet stuur door naar lijst 2
            $sql_l2=mysql_query(
                "SELECT Provincie
                FROM partner
                WHERE id = "
. intval($_SESSION['id']) . "
                ORDER BY id"
);
            if ($sql_l2===false)
                {
echo"Er is een fout op regel " . __LINE__ ; }
            else {  $info = mysql_fetch_row($sql_l2);
                if ($info[0] == '')
                    {
$_POST['controle']="FALSE";
                    header('Location: lijst2.php'); }
                else { //Ga naar profiel
                    if(mysql_num_rows($sql_inlog) == 1)
                        {
$_SESSION['username']=$_POST[username];
                        $_SESSION['id']=$sql_inlog;
                        header('Location: profiel.php'); }
                    else
                        { $_SESSION['error_inlog']="Verkeerde combinatie ingevuld!";
                        header('Location: index.html'); }
                    }
                }
            }
        }
    }



?>


Lijst1 script:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<?php
session_start();
IF ($_POST['controle']=="TRUE") {
$con = mysql_connect("localhost","root","") or die('Could not connect: ' . mysql_error());
mysql_select_db("datingsite", $con) or die('Could not find database: ' . mysql_error());

IF (
   (
empty($_POST['voornaam']))
OR (empty($_POST['achternaam']))
OR (empty($_POST['geslacht']))
OR (empty($_POST['beroep']))
OR ($_POST['provincie']=="Provincie")
OR ($_POST['religie']=="Religie")
OR ($_POST['opleiding']=="Opleiding")
OR ($_POST['huidskleur']=="Huidskleur")
OR ($_POST['haarkleur']=="Haarkleur")
OR ($_POST['oogkleur']=="Oogkleur")
OR (empty($_POST['roken']))
)
    {
$error_head="<b>!! ERROR !!</b>";
        $error="1"; }
IF ($error)
    {

IF (empty($_POST['voornaam']))
    {
$error_voornaam="Je hebt je <u>Voornaam</u> niet ingevuld!<br />"; }
IF (empty($_POST['achternaam']))
    {
$error_achternaam="Je hebt je <u>Achternaam</u> niet ingevuld!<br />"; }
IF (empty($_POST['geslacht']))
    {
$error_geslacht="Je hebt je <u>Geslacht</u> niet ingevuld!<br />"; }
IF (empty($_POST['beroep']))
    {
$error_beroep="Je hebt je <u>Beroep</u> niet ingevuld!<br />"; }
IF ($_POST['provincie']=="Provincie")
    {
$error_provincie="Je hebt je <u>Provincie</u> niet ingevuld!<br />"; }
IF ($_POST['religie']=="Religie")
    {
$error_religie="Je hebt je <u>Religie</u> niet ingevuld!<br />"; }
IF ($_POST['opleiding']=="Opleiding")
    {
$error_opleiding="Je hebt je <u>Opleiding</u> niet ingevuld! <br />"; }
IF ($_POST['huidskleur']=="Huidskleur")
    {
$error_huidskleur="Je hebt je <u>Huidskleur</u> niet ingevuld! <br />"; }
IF ($_POST['haarkleur']=="Haarkleur")
    {
$error_haarkleur="Je hebt je <u>Haarkleur</u> niet ingevuld! <br />"; }
IF ($_POST['oogkleur']=="Oogkleur")
    {
$error_oogkleur="Je hebt je <u>Oogkleur</u> niet ingevuld! <br />"; }
IF (empty($_POST['roken']))
    {
$error_roken="Je hebt je <u>Roken</u> niet ingevuld! <br />"; }
IF ($_POST['kinderen']=="Kinderen")
    {
$error_kinderen="Je hebt je huidige <u>aantal Kinderen</u> niet ingevuld! <br />"; }
IF ($_POST['kinderwens']=="Kinderwens")
    {
$error_kinderwens="Je hebt je <u>Kinderwens</u> niet ingevuld! <br />"; }
}


else {
$sql=mysql_query(" UPDATE user
SET voornaam='"
.$_POST[voornaam]."', achternaam='".$_POST[achternaam]."', geslacht='".$_POST[geslacht]."', beroep='".$_POST[beroep]."', provincie='".$_POST[provincie]."',
    religie='"
.$_POST[religie]."', opleiding='".$_POST[opleiding]."', huidskleur='".$_POST[huidskleur]."', haarkleur='".$_POST[haarkleur]."', oogkleur='".$_POST[oogkleur]."',
    roken='"
.$_POST[roken]."', kinderen='".$_POST[kinderen]."', kinderwens='".$_POST[kinderwens]."'
WHERE username='"
.$_SESSION['username']."' ");

IF (!mysql_query($sql, $con))
    {
die ("Error: " . mysql_error()); }
}
mysql_close($con);
}
?>


<html>
<head>
<title>Profiel invullen - #1</title>
</head>
<body>
<center><a href="loguit.php"><img border="0" src="/Dating/WIP/Forever_Alone_Dating.png" alt="Forever Alone Dating logo" width="256" height="183"></a></center> <br />
<font color="#FF0000"><?php echo $error_head;?><br /></font>
<?php echo $_SESSION['id']; ?>
<table>
<form action="" method="post">

<tr> <td width="250">Wat is uw Voornaam?</td>
<td width="100"><input type="text" name="voornaam" size="30" value="<?php echo "$_POST[voornaam]"; ?>"></td>
<td width="10"></td> <td width="600"><font color="#FF0000"> <?php echo $error_voornaam; ?> </font> </td></tr>

<tr><td>Wat is uw Achternaam?</td>
<td><input type="text" name="achternaam" size="30" value="<?php echo "$_POST[achternaam]"; ?>"></td>
<td></td> <td><font color="#FF0000"> <?php echo $error_achternaam; ?> </font> </td></tr>

<tr><td>Bent u een Man of een Vrouw?</td>
<td><input type="radio" value="man" name="geslacht">Man
<input type="radio" value="vrouw" name="geslacht">Vrouw</td>
<td></td> <td><font color="#FF0000"> <?php echo $error_geslacht; ?> </font> </td></tr>

<tr><td>Wat is uw Beroep?</td>
<td><input type="text" name="beroep" size="30" value="<?php echo "$_POST[beroep]"; ?>"></td>
<td></td> <td><font color="#FF0000"> <?php echo $error_beroep; ?> </font> </td></tr>

<tr><td><span>In welke Provincie woont u?</span></td>
<td>
<?php
//zet de provincies in een array om deze te gebruiken in de selectbox van de provincie
$provincie = array("Provincie", "Drenthe", "Flevoland", "Friesland", "Gelderland", "Groningen", "Limburg",
    "Noord-Brabant", "Noord-Holland", "Overijssel", "Utrecht", "Zeeland", "Zuid-Holland");
//selectbox van de provincie
//gebruik $provincie[$p-1] omdat een array bij 0 begint

echo '<select name="provincie">';
for($p=1;$p<=13;$p++){
   if($p == $_POST["provincie"]){$selected = 'selected="selected"';}else{$selected = '';}
   echo '<option value="'.$p.'" '.$selected.'>'.$provincie[$p-1].'</option>'; }
echo '</select>';
?>

</td> <td></td> <td><font color="#FF0000"> <?php echo $error_provincie; ?> </font> </td></tr>

<tr><td><span>Wat is uw Religie?</span></td>
<td><?php
//zet de provincies in een array om deze te gebruiken in de selectbox van de provincie
$religie = array("Religie", "Christelijk", "Katholiek", "Hervormd", "Protestants", "Gereformeerd", "Moslim",
    "Boeddhisme", "Hindoeisme", "Jodendom", "Overig", "Niet Gelovig");
//selectbox van de provincie
//gebruik $provincie[$p-1] omdat een array bij 0 begint

echo '<select name="religie">';
for($r=1;$r<=12;$r++){
   if($r == $_POST["religie"]){$selected = 'selected="selected"';}else{$selected = '';}
   echo '<option value="'.$r.'" '.$selected.'>'.$religie[$r-1].'</option>'; }
echo '</select>';
?>
</td>
<td></td> <td><font color="#FF0000"> <?php echo $error_religie; ?> </font> </td></tr>    

<tr><td><span>Wat is uw hoogst behaalde opleiding?</span></td>
<td><?php
//zet de provincies in een array om deze te gebruiken in de selectbox van de provincie
$opleiding = array("Opleiding", "VMBO", "HAVO", "VWO", "Gymnasium", "Middelbaar Beroepsonderwijs", "Hoger Beroepsonderwijs",
    "Universitair");
//selectbox van de provincie
//gebruik $provincie[$p-1] omdat een array bij 0 begint

echo '<select name="opleiding">';
for($op=1;$op<=8;$op++){
   if($op == $_POST["opleiding"]){$selected = 'selected="selected"';}else{$selected = '';}
   echo '<option value="'.$op.'" '.$selected.'>'.$opleiding[$op-1].'</option>'; }
echo '</select>';
?>
</td>
<td></td> <td><font color="#FF0000"> <?php echo $error_opleiding; ?> </font> </td></tr>

<tr><td><span>Wat is uw huidskleur?</span></td>
<td><?php
//zet de provincies in een array om deze te gebruiken in de selectbox van de provincie
$huidskleur = array("Huidskleur", "Blank", "Licht Getint", "Middel Getint", "Zeer Getint", "Bruin", "Zwart");
//selectbox van de provincie
//gebruik $provincie[$p-1] omdat een array bij 0 begint

echo '<select name="huidskleur">';
for($hu=1;$hu<=7;$hu++){
   if($hu == $_POST["huidskleur"]){$selected = 'selected="selected"';}else{$selected = '';}
   echo '<option value="'.$hu.'" '.$selected.'>'.$huidskleur[$hu-1].'</option>'; }
echo '</select>';
?>
</td>
<td></td> <td><font color="#FF0000"> <?php echo $error_huidskleur; ?> </font> </td></tr>

<tr><td><span>Wat is uw haarkleur?</span></td>
<td><?php
//zet de provincies in een array om deze te gebruiken in de selectbox van de provincie
$haarkleur = array("Haarkleur", "Wit", "Licht Blond", "Blond", "Licht Bruin", "Bruin",
    "Grijs", "Zwart", "Licht Rood", "Rood", "Overig");
//selectbox van de provincie
//gebruik $provincie[$p-1] omdat een array bij 0 begint

echo '<select name="haarkleur">';
for($ha=1;$ha<=11;$ha++){
   if($ha == $_POST["haarkleur"]){$selected = 'selected="selected"';}else{$selected = '';}
   echo '<option value="'.$ha.'" '.$selected.'>'.$haarkleur[$ha-1].'</option>'; }
echo '</select>';
?>
</td>
<td></td> <td><font color="#FF0000"> <?php echo $error_haarkleur; ?> </font> </td></tr>

<tr><td><span>Wat is uw oogkleur?</span></td>
<td><?php
//zet de provincies in een array om deze te gebruiken in de selectbox van de provincie
$oogkleur = array("Oogkleur");
//selectbox van de provincie
//gebruik $provincie[$p-1] omdat een array bij 0 begint

echo '<select name="oogkleur">';
for($og=1;$og<=1;$og++){
   if($og == $_POST["oogkleur"]){$selected = 'selected="selected"';}else{$selected = '';}
   echo '<option value="'.$og.'" '.$selected.'>'.$oogkleur[$og-1].'</option>'; }
echo '</select>';
?>
</td>
<td></td> <td><font color="#FF0000"> <?php echo $error_oogkleur; ?> </font> </td></tr>

<tr><td>Rookt U?</td>
<td><input type="radio" value="wel" name="roken">Ik rook wel
<input type="radio" value="niet" name="roken">Ik rook niet</td>
<td></td> <td><font color="#FF0000"> <?php echo $error_roken; ?> </font> </td></tr>

<tr><td><span>Hoeveel kinderen hebt U?</span></td>
<td><select name="kinderen">
    <option value="Kinderen">Kinderen</option>            <option value="0">0</option>
    <option value="1">1</option>                        <option value="2">2</option>
    <option value="3">3</option>                        <option value="4">4</option>
    <option value="5meer">5 of meer</option>            </select></td>
    <td></td> <td><font color="#FF0000"> <?php echo $error_kinderen; ?> </font> </td></tr>

<tr><td><span>Hoeveel kinderen wilt U nog?</span></td>
<td><select name="kinderwens">
    <option value="Kinderwens">Kinderwens</option>            <option value="0">0</option>
    <option value="1">1</option>                        <option value="2">2</option>
    <option value="3">3</option>                        <option value="4">4</option>
    <option value="5meer">5 of meer</option>            </select></td>
    <td></td> <td><font color="#FF0000"> <?php echo $error_kinderwens; ?> </font> </td></tr>
    
</table><br />
<input type="hidden" name="controle" value="TRUE">
<input type="submit" value="Versturen!">
</form>
<hr>
<form name="reset" method="post" action="<?php echo ($_SERVER["PHP_SELF"]);?>">
<input type="submit" name="submit" value="Reset"><br />
</form>
</body>
</html>


Toevoeging op 18/11/2012 13:13:22:

En het stukje bij lijst1 met de span enzo ga ik nog anders doen, dit schrijft alleen getallen weg. Dat wil ik niet, ik wil het woord in de array wat daarbij hoort. Ik ga dus met option value werken, de html manier zegmaar.
 

Pagina: « vorige 1 2



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.