Jump to content
php.lv forumi

Apdeitojot mysql tabulu kļūda


xfr33

Recommended Posts

Labdien!

Tātad updeitojot tabulu mysql vienīgais, uz ko apdeito ir "0". Var ievadīt jebkuru informāciju, bet apdeitos uz 0. Kāds var palīdzēt?

 

<?php

session_start();

$c = mysql_connect("localhost", "root", "") or die(mysql_error());
$d = mysql_select_db("a2599236_users", $c);

$username = $_SESSION['username'];
$email = $_POST['email'];
$name = $_POST['name'];
$surname = $_POST['surname'];
$password = $_SESSION['password'];

$result = mysql_query("UPDATE users SET email='$email' AND name='$name' AND surname='$surname' WHERE username='$username'") or die(mysql_error);

header('Location:profile.php');
?>

 

 

<?php

session_start();

$c = mysql_connect("localhost", "root", "") or die(mysql_error());
$d = mysql_select_db("a2599236_users", $c);

$data = mysql_query("SELECT * FROM users WHERE username=\"". $_SESSION['username'] ."\"") or die(mysql_error);
while($info = mysql_fetch_array( $data )) {
echo "<form action=\"profile_edit.php\" method=\"post\">
Lietotājvārds: <br />
<input type=\"text\" name=\"username\" value=\"". $info['username'] ."\" /><br />
Epasta adrese: <br />
<input type=\text\" name=\"email\" value=\"". $info['email'] ."\" /><br />
Vards: <br />
<input type=\"text\" name=\"name\" value=\"". $info['name'] ."\" /><br />
Uzvards: <br />
<input type=\"text\" name=\"surname\" value=\"". $info['surname'] ."\" /><br />
<input type=\"submit\" value=\"Saglabat izmainas\" />
</form>";
}
?>

 

 

Jau iepriekš paldies!

Link to comment
Share on other sites

$result = mysql_query("UPDATE users SET email='$email' AND name='$name' AND surname='$surname' WHERE username='$username'") or die(mysql_error);

 

$result = mysql_query("UPDATE users SET email='$email', name='$name', surname='$surname' WHERE username='$username'") or die(mysql_error());

 

Neko daudz nepetiju, bet lieta ko uzreiz ieraudzīju bija nepareizs kvērijs sql..

Link to comment
Share on other sites

1) lieto mysql_real_escape_string(), piem $email = mysql_real_escape_string($_POST['email']);, savādāk tava sistēma būs caurstaigājama ( varēs ienākt katrs, kam nav slinkums).

2) "UPDATE users SET email='$email', name='$name', surname='$surname' WHERE username='$username'";

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...