Chcia³em do formularza dodaæ jeszcze jedno pole a poniewa¿ w ogóle siê nie znam na php ani mysql skopiowa³em linijki z kodu które zawira³y nazwy pól formularza i wstawia³em inne nazwy. Doda³em te¿ nowe pole w bazie mysql w tabeli users o tej samej nazwie co w kodzie php i warto¶ciami co inne pola w tabeli bazy.
Niestety co¶ jest nie tak poniewa¿ gdy robiê na stronie "zapisz dane" pojawia mi siê b³±d:
Cytat
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 'mod='', shoe=''WHERE uid='40'' at line 21
update users set password='8mvw0vv0p', first_name='', last_name='', street='', city='', state='', zip='', country='', email='', cat='', telephone='', age='', chest='', height='', weight='', waist='', eyes='', hair='', dress='', mod='', shoe=''WHERE uid='40'
update users set password='8mvw0vv0p', first_name='', last_name='', street='', city='', state='', zip='', country='', email='', cat='', telephone='', age='', chest='', height='', weight='', waist='', eyes='', hair='', dress='', mod='', shoe=''WHERE uid='40'
Kod wygl±da tak:
<? include("include/common.php"); if(!$loggedin){ } include("include/header.php"); include("include/accmenu.php"); if($submit){ $sql = "update users set password='$spassword', first_name='$sfirst_name', last_name='$slast_name', street='$sstreet', city='$scity', state='$sstate', zip='$szip', country='$scountry', email='$semail', cat='$scat', telephone='$stelephone', age='$sage', chest='$schest', height='$sheight', weight='$sweight', waist='$swaist', eyes='$seyes', hair='$shair', dress='$sdress', mod='$smod', <----------------------------------- doda³em tê linijkê shoe='$sshoe'WHERE uid='$myuid'"; ?> <h3>Edytuj Swoje Dane</h3> <form action=account.php method=post> <?=$table2?> <tr align=center> <td colspan=2>Dane zosta³y zapisane.</td> </tr> <? if ($cpassword != $spassword) { echo "<tr align=center><td colspan=2>Musisz siê wylogowaæ <a href=logout.php>tutaj</a> i zalogowaæ ponownie. Upewnij siê, ¿e nie masz otwartych wiêcej okien z t± s
am± stron±.</td></tr>"; } }else{ $cusername = $this->d->username; $cpassword = $this->d->password; $cfirst_name = $this->d->first_name; $clast_name = $this->d->last_name; $cstreet = $this->d->street; $ccity = $this->d->city; $czip = $this->d->zip; $cstate = $this->d->state; $ccountry = $this->d->country; $cemail = $this->d->email; $ctelephone = $this->d->telephone; $clast_paid = $this->d->last_paid; $ccat = $this->d->cat; $csignup_date = $this->d->signup_date; $cage = $this->d->age; $cchest = $this->d->chest; $cheight = $this->d->height; $cweight = $this->d->weight; $cwaist = $this->d->waist; $ceyes = $this->d->eyes; $chair = $this->d->hair; $cdress = $this->d->dress; $cshoe = $this->d->shoe; $cmod = $this->d->mod; <----------------------------------- doda³em tê linijkê } ?> <h3>Edytuj Swoje Dane</h3> <form method=post> <?=$table2?> <tr align=center> <td colspan=2>Pola <b>pogrubione</b> s± obowi±zkowe! W razie problemów prosimy o kontakt.<p></td> </tr> <tr> <td align=right>Login:</td> <td><?=$cusername?></td></tr> <tr> <td align=right><b>Has³o:</b></td> <td><input type=text name=spassword size=35 maxlength=15 value='<?=$cpassword?>'></td></tr> <tr> <td align=right><b>Imiê:</b></td> <td><input type=text name=sfirst_name size=35 maxlength=20 value='<?=$cfirst_name?>'></td></tr> <tr> <td align=right>Nazwisko:</td> <td><input type=text name=slast_name size=35 maxlength=30 value='<?=$clast_name?>'></td></tr> <tr> <td align=right>Ulica:</td> <td><input type=text name=sstreet size=35 maxlength=50 value='<?=$cstreet?>'></td></tr> <tr> <td align=right><b>Miasto:</b></td> <td><input type=text name=scity size=35 maxlength=30 value='<?=$ccity?>'></td></tr> <tr> <td align=right><b>Województwo:</b></td> <td><input type=text name=sstate size=35 maxlength=30 value='<?=$cstate?>'></td></tr> <tr> <td align=right>Kod pocztowy:</td> <td><input type=text name=szip size=35 maxlength=10 value='<?=$czip?>'></td></tr> <tr> <td align=right><b>Kraj</b>:</td> <td><input type=text name=scountry size=35 maxlength=30 value='<?=$ccountry?>'></td></tr> <tr> <td align=right><b>Email:</b></td> <td><input type=text name=semail size=35 maxlength=75 value='<?=$cemail?>'></td></tr> <tr> <td align=right>Telefon:</td> <td><input type=text name=stelephone size=35 maxlength=12 value='<?=$ctelephone?>'></td></tr> <tr> <td align=right><b>Kategoria:</b></td> <td><? buildCatBox("scat",$ccat) ?> <tr> <td align=right><b>Rok urodzenia:</b> <td><input type=text name=sage size=35 maxlength=75 value='<?=$cage?>'></td></tr> <tr> <td align=right>Kolor oczu: <td><input type=text name=seyes size=35 maxlength=75 value='<?=$ceyes?>'></td></tr> <tr> <td align=right>kolor w³osów: <td><input type=text name=shair size=35 maxlength=75 value='<?=$chair?>'></td></tr> <tr> <td align=right><b>Biust:</b> <td><input type=text name=schest size=35 maxlength=75 value='<?=$cchest?>'></td></tr> <tr> <td align=right><b>Wzrost:</b> <td><input type=text name=sheight size=35 maxlength=75 value='<?=$cheight?>'></td></tr> <tr> <td align=right><b>Talia:</b> <td><input type=text name=sweight size=35 maxlength=75 value='<?=$cweight?>'></td></tr> <tr> <td align=right><b>Biodra:</b> <td><input type=text name=swaist size=35 maxlength=75 value='<?=$cwaist?>'></td></tr> <tr> <td align=right><b>P1:</b> <--------------------------------------------- doda³em tê linijkê i poni¿ej <td><input type=text name=sdress size=35 maxlength=75 value='<?=$cmod?>'> (Tak/Nie)</td></tr> <tr> <td align=right><b>P2</b> <td><input type=text name=sshoe size=35 maxlength=75 value='<?=$cfmod?>'></td></tr> <tr> <td align=right><b>P3</b> <td><input type=text name=sshoe size=35 maxlength=75 value='<?=$chost?>'></td></tr> <tr>
cd kodu:
<td align=right><b>P4</b> <td><input type=text name=sshoe size=35 maxlength=75 value='<?=$cta?>'></td></tr> <tr> <td> </td><td><input type=submit name=submit value='Zapisz zmiany'></td></tr> </table> </form> <? } include("include/footer.php"); ?> <? function buildCatBox($name,$sel=""){ ?> <SELECT NAME="<?=$name?>"> <option value="">----- <? if($sel == $a->id){ }else{ } } ?> </select> <? } function getCat($cat){ return $a->name; } ?>
Co tu trzeba zrobiæ ¿eby wszystko dobrze dzia³a³o?
