1

got this:

if (mysql_num_rows($ak) == 0) {
    $sonuc = mysql_query($sql) or die(mysql_error());
}
elseif (mysql_num_rows($ak) == 1) {
    $sonuc = "you already added";
}

this script works succesfully. but mysql_query($sql) echos "1" how can let it echo "successfully added." thanks...

(im asking simple questions because im new to php)

2 Answers 2

2
$sonuc = mysql_query($sql) or die(mysql_error());
if($sonuc) {
   echo "successfully added.";
}

But as you have or die(mysql_error()) this is also valid (but easier to mess up with when you change code):

$sonuc = mysql_query($sql) or die(mysql_error());
echo "successfully added.";
Sign up to request clarification or add additional context in comments.

2 Comments

kk fixed added ; to end of echo
Add a semicolon to the end of the echo line.
0

Try this:

if (mysql_num_rows($ak) == 0) {
    $ak = mysql_query($sql) or die(mysql_error());
    $sonuc = "successfully added";
}
elseif (mysql_num_rows($ak) == 1) {
    $sonuc = "you already added";
}

echo $sonuc;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.