B*h PHP - SQL How To Column

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »

51 Replies - 2691 Views - Last Post: 30 August 2015 - 02:49 AM Rate Topic: -----

#1 eralpcicekdagi   User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 42
  • Joined: 11-August 15

B*h PHP - SQL How To Column

Posted 28 August 2015 - 09:52 AM

Hello is it my code true?

On my code i tried to do get level from sql and reedem to $level

<?
$level=mysql_query("SELECT level from skor WHERE oyuncuadi='".$oyuncuadi."'");

?>

and the second code i tried to update if exp bigger than needexp
<?
if($exp>$needexp)
{
$level++
mysql_query("UPDATE skor SET level='".$level."' WHERE oyuncuadi='".$oyuncuadi."'");
}

?>[/code]

my table name: skor

Is This A Good Question/Topic? 0
  • +

Replies To: B*h PHP - SQL How To Column

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14409
  • View blog
  • Posts: 57,772
  • Joined: 12-June 08

Re: B*h PHP - SQL How To Column

Posted 28 August 2015 - 09:54 AM

I am confused - what is the question?

You should be able to tell pretty quickly if that code works or not when you run the page.
Was This Post Helpful? 0
  • +
  • -

#3 andrewsw   User is offline

  • Entwickler
  • member icon

Reputation: 6602
  • View blog
  • Posts: 26,897
  • Joined: 12-December 12

Re: B*h PHP - SQL How To Column

Posted 28 August 2015 - 09:55 AM

If you are asking if your code works then you could find out most easily by running and testing it.
Was This Post Helpful? 0
  • +
  • -

#4 eralpcicekdagi   User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 42
  • Joined: 11-August 15

Re: B*h PHP - SQL How To Column

Posted 28 August 2015 - 09:59 AM

where can i test it?

yes im asking is it my code true
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14409
  • View blog
  • Posts: 57,772
  • Joined: 12-June 08

Re: B*h PHP - SQL How To Column

Posted 28 August 2015 - 10:02 AM

Run your code. If it works as you expect then it is sound. If it doesn't work then you need to start debugging it.
Was This Post Helpful? 0
  • +
  • -

#6 andrewsw   User is offline

  • Entwickler
  • member icon

Reputation: 6602
  • View blog
  • Posts: 26,897
  • Joined: 12-December 12

Re: B*h PHP - SQL How To Column

Posted 28 August 2015 - 10:02 AM

You need a web server. You could install a LAMPP stack, WAMP or XAMPP. Or you could run it from a live site.

But how did you get the stage of writing against MySQL without ever having run a PHP script?
Was This Post Helpful? 1
  • +
  • -

#7 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6698
  • View blog
  • Posts: 31,068
  • Joined: 10-May 07

Re: B*h PHP - SQL How To Column

Posted 28 August 2015 - 10:03 AM

View Postandrewsw, on 28 August 2015 - 01:02 PM, said:

But how did you get the stage of writing against MySQL without ever having run a PHP script?


I too am interested in this.
Was This Post Helpful? 0
  • +
  • -

#8 eralpcicekdagi   User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 42
  • Joined: 11-August 15

Re: B*h PHP - SQL How To Column

Posted 28 August 2015 - 10:18 AM

i tried my code

- 
<?
session_start();
$exppuan=mysql_query("SELECT exppuan from skor WHERE oyuncuadi='".$oyuncuadi."'");
$skor=$_POST['skor'];

if ($skor>=0)
{
$exp2puan=$exppuan+$skor/2;
mysql_query("UPDATE skor SET exppuan='".$exp2puan."' WHERE oyuncuadi='".$oyuncuadi."'");
}
?> 
-



where did i do wrong?
Was This Post Helpful? 0
  • +
  • -

#9 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14409
  • View blog
  • Posts: 57,772
  • Joined: 12-June 08

Re: B*h PHP - SQL How To Column

Posted 28 August 2015 - 10:20 AM

Your tried it and what happened? Was there an error? If so copy/paste the error text here. Did it not work as expected? If so then explain what did happen and what you were expecting.
Was This Post Helpful? 0
  • +
  • -

#10 eralpcicekdagi   User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 42
  • Joined: 11-August 15

Re: B*h PHP - SQL How To Column

Posted 28 August 2015 - 10:23 AM

my error is

if my score is 500 my exp will be 250 but,
on sql it is not add to my exppuan again.


I'm trying to say
if my exp is 100
and when i died on game if my score 500 my exp will be 250

but its not be like this: 100+250=350
it only write 250

This post has been edited by eralpcicekdagi: 28 August 2015 - 10:23 AM

Was This Post Helpful? 0
  • +
  • -

#11 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6698
  • View blog
  • Posts: 31,068
  • Joined: 10-May 07

Re: B*h PHP - SQL How To Column

Posted 28 August 2015 - 10:23 AM

Please provide output from the following :

$sql = "SELECT exppuan from skor WHERE oyuncuadi=".$oyuncuadi;
$exppuan=mysql_query($sql);
if(!$exppuan) {
  echo "The following SQL failed";
  echo $sql;
}



Your code starts php on line 2, & then uses a variable on line 4. My guess is either that variable doesn't have a value, or you are taking for granted what the sql is doing.

Visually verify, & replicate. That is the best way I find troubleshooting errors. Not by looking at the code, but by visually verifying what it is doing.
Was This Post Helpful? 0
  • +
  • -

#12 eralpcicekdagi   User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 42
  • Joined: 11-August 15

Re: B*h PHP - SQL How To Column

Posted 28 August 2015 - 10:28 AM

http://agarw.com/skor.php
your code is not the true way.
I have the problem about getting exp point
or adding exp point to new exps.

This post has been edited by andrewsw: 28 August 2015 - 10:29 AM
Reason for edit:: Removed previous quote, just press REPLY

Was This Post Helpful? 0
  • +
  • -

#13 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6698
  • View blog
  • Posts: 31,068
  • Joined: 10-May 07

Re: B*h PHP - SQL How To Column

Posted 28 August 2015 - 10:29 AM

View Posteralpcicekdagi, on 28 August 2015 - 01:28 PM, said:

your code is not the true way.

My code shows you the error.
Was This Post Helpful? 0
  • +
  • -

#14 eralpcicekdagi   User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 42
  • Joined: 11-August 15

Re: B*h PHP - SQL How To Column

Posted 28 August 2015 - 10:30 AM

i added your code to my php file what is my error?
Was This Post Helpful? 0
  • +
  • -

#15 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6698
  • View blog
  • Posts: 31,068
  • Joined: 10-May 07

Re: B*h PHP - SQL How To Column

Posted 28 August 2015 - 10:32 AM

I'll repost this, please read it this time, instead of copy & paste & hope for a solution :

View Postno2pencil, on 28 August 2015 - 01:23 PM, said:

Please provide output from the following :

$sql = "SELECT exppuan from skor WHERE oyuncuadi=".$oyuncuadi;
$exppuan=mysql_query($sql);
if(!$exppuan) {
  echo "The following SQL failed";
  echo $sql;
}



Your code starts php on line 2, & then uses a variable on line 4. My guess is either that variable doesn't have a value, or you are taking for granted what the sql is doing.

Visually verify, & replicate. That is the best way I find troubleshooting errors. Not by looking at the code, but by visually verifying what it is doing.

Was This Post Helpful? 0
  • +
  • -

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »