Witam. Miałem gotowy kod który zapisauje dane do bazy mysql.
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'
Kod wygląda tak:
<?
include("include/common.php");
if(!$loggedin){
header("Location: login.php"); }
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{
$this->c=mysql_query("select * from users where uid='$myuid'"); $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="">-----
<?
$qr1 = mysql_query("SELECT * FROM cats ORDER BY name ASC"); if($sel == $a->id){
echo "<OPTION VALUE="{$a->id}" SELECTED>{$a->name}</OPTION>n"; }else{
echo "<OPTION VALUE="{$a->id}">{$a->name}</OPTION>n"; }
}
?>
</select>
<?
}
function getCat($cat){
$qr1 = mysql_query("SELECT name FROM cats WHERE id='$cat'"); return $a->name;
}
?>
Co tu trzeba zrobić żeby wszystko dobrze działało?