Pomoc - Szukaj - U¿ytkownicy - Kalendarz
Pe³na wersja: [mysql][php]
Forum PHP.pl > Forum > Przedszkole
molesta
Witam mam pytanie chce wykonac INSERT ale nie moge sobie poradzić z prawidłowa składnia
Jest tabelu User i pola Username i status

Chciałbym aby w tabeli User dodał wartość "tak" do pola  "status" gdzie nazwa uzytkownika to login przekazywany w sesji

Próbowałem tak ale wywala błedy ze składnią
  1. <?php
  2. $query = mysql_query("INSERT INTO Users WHER Username = $_SESSION['s_username'] (status) VALUE (tak)") or die(mysql_error());
  3. ?>


Prosze o pomoc bo nie moge sobie z tym poradzić
marcio
  1. <?php
  2. $query = mysql_query('INSERT INTO Users(status) VALUE ("tak") WHERE Username = "'.$_SESSION['s_username'].'"') or die(mysql_error());
  3. ?>

Powinno byc dobrze jak nie to uzyj update

P.S lejto w sumie tak zapomnialo mi sie nigdy nioe robielm polecenia insert z kaluzule where wiec nie wiedzialem smile.gif
Lejto
to chyba update musi byæ no nie? jak masz where
-anonim-
<?php
$query = mysql_query("INSERT INTO Users WHER Username = $_SESSION['s_username'] (status) VALUE (tak)") or die(mysql_error());
?>
  1. <?php
  2. $status = $_SESSION['s_username'] 
  3. //musisz zdefiniowaæ zmienn± $user gdzie jest login usera
  4. $query = mysql_query("INSERT INTO Users (status) VALUES ('$status') WHERE Username = '$user'");
  5. ?>
marcio
Czyli
  1. <?php
  2. $query = ('update users set status = "tak" where Username = "'.$_SESSION['s_username'].'"');
  3. ?>
molesta
Niedzia³a :/
Mo¿e ja dok³adniej wyt³umacze o co mi chodzi
Integruje PayPal ze stron± i po weryfikacji platno¶ci powinien dodaæ do pola status warto¶æ "tak"
oto ca³y kod:
  1. <?php
  2. include 'process.php';
  3. echo 'jestes zalogowany jako '.$_SESSION['s_username'].'';
  4. /* PHP Paypal IPN Integration Class Demonstration File
  5.  * 4.16.2005 - Micah Carrick, email@micahcarrick.com
  6.  *
  7.  * This file demonstrates the usage of paypal.class.php, a class designed 
  8.   * to aid in the interfacing between your website, paypal, and the instant
  9.  * payment notification (IPN) interface. This single file serves as 4 
  10.  * virtual pages depending on the "action" varialble passed in the URL. It's
  11.  * the processing page which processes form data being submitted to paypal, it
  12.  * is the page paypal returns a user to upon success, it's the page paypal
  13.  * returns a user to upon canceling an order, and finally, it's the page that
  14.  * handles the IPN request from Paypal.
  15.  *
  16.  * I tried to comment this file, aswell as the acutall class file, as well as
  17.  * I possibly could. Please email me with questions, comments, and suggestions.
  18.  * See the header of paypal.class.php for additional resources and information.
  19. */
  20.  
  21. // Setup class
  22. require_once('paypal.class.php'); // include the class file
  23. $p = new paypal_class;  // initiate an instance of the class
  24. $p->paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';  // testing paypal url
  25. //$p->paypal_url = 'https://www.paypal.com/cgi-bin/webscr';  // paypal url
  26. // setup a variable for this script (ie: 'http://www.micahcarrick.com/paypal.php')
  27. $this_script = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
  28.  
  29. // if there is not action variable, set the default action of 'process'
  30. if (empty($_GET['action'])) $_GET['action'] = 'process'; 
  31.  
  32. switch ($_GET['action']) {
  33.  case 'process': // Process and order...
  34.  
  35. // There should be no output at this point. To process the POST data,
  36. // the submit_paypal_post() function will output all the HTML tags which
  37. // contains a FORM which is submited instantaneously using the BODY onload
  38. // attribute. In other words, don't echo or printf anything when you're
  39. // going to be calling the submit_paypal_post() function.
  40.  // This is where you would have your form validation and all that jazz.
  41. // You would take your POST vars and load them into the class like below,
  42. // only using the POST values instead of constant string expressions.
  43.  // For example, after ensureing all the POST variables from your custom
  44. // order form are valid, you might have:
  45. //
  46. // $p->add_field('first_name', $_POST['first_name']);
  47. // $p->add_field('last_name', $_POST['last_name']);
  48. $p->add_field('business', 'biuro_1207418552_biz@pangram.pl');
  49. $p->add_field('return', $this_script.'?action=success');
  50. $p->add_field('cancel_return', $this_script.'?action=cancel');
  51. $p->add_field('notify_url', $this_script.'?action=ipn');
  52. $p->add_field('item_name', 'Payment for access to chmod.pangram.pl for user '.$_SESSION['s_username'].'');
  53. $p->add_field('amount', '1.99');
  54.  
  55. $p->submit_paypal_post(); // submit the fields to paypal
  56. //$p->dump_fields(); // for debugging, output a table of all the fields
  57. break;
  58.  case 'success':
  59.  $query = ('UPDATE Users SET status = "tak" where Username = "'.$_SESSION['s_username'].'"');
  60.  
  61. // This is where you would probably want to thank the user for their order
  62. // or what have you. The order information at this point is in POST 
  63. // variables. However, you don't want to "process" the order until you
  64. // get validation from the IPN. That's where you would have the code to
  65. // email an admin, update the database with payment status, activate a
  66. // membership, etc. 
  67. echo "<html><head><title>Success</title></head><body><h3>Thank you for your order.</h3>";
  68. foreach ($_POST as $key => $value) { echo "$key: $value<br>"; }
  69. echo "</body></html>";
  70. // You could also simply re-direct them to another page, or your own 
  71. // order status page which presents the user with the status of their
  72. // order based on a database (which can be modified with the IPN code 
  73. // below).
  74. break;
  75.  case 'cancel':  // Order was canceled...
  76.  
  77. // The order was canceled before being completed.
  78.  echo "<html><head><title>Canceled</title></head><body><h3>The order was canceled.</h3>";
  79. echo "</body></html>";
  80. break;
  81.  case 'ipn': // Paypal is calling page for IPN validation...
  82.  // It's important to remember that paypal calling this script. There
  83. // is no output here. This is where you validate the IPN data and if it's
  84. // valid, update your database to signify that the user has payed. If
  85. // you try and use an echo or printf function here it's not going to do you
  86. // a bit of good. This is on the "backend". That is why, by default, the
  87. // class logs all IPN data to a text file.
  88. if ($p->validate_ipn()) {
  89.  // Payment has been recieved and IPN is verified. This is where you
  90.  // update your database to activate or process the order, or setup
  91.  // the database with the user's order details, email an administrator,
  92.  // etc. You can access a slew of information via the ipn_data() array.
  93.  // Check the paypal documentation for specifics on what information
  94.  // is available in the IPN POST variables. Basically, all the POST vars
  95.  // which paypal sends, which we send back for validation, are now stored
  96.  // in the ipn_data() array.
  97.  // For this example, we'll just email ourselves ALL the data.
  98.  $subject = 'Instant Payment Notification - Recieved Payment';
  99.  $to = 'biuro@pangram.pl'; // your email
  100.  $body = "An instant payment notification was successfully recieved\n";
  101.  $body .= "from ".$p->ipn_data['payer_email']." on ".date('m/d/Y');
  102.  $body .= " at ".date('g:i A')."\n\nDetails:\n";
  103. foreach ($p->ipn_data as $key => $value) { $body .= "\n$key: $value"; }
  104.  mail($to, $subject, $body);
  105. }
  106. break;
  107.  } 
  108.  
  109. ?>


prosze zerknaæ na fragment
  1. <?php
  2. case 'success':
  3. ?>


Jest on odpowiedzialny za funkcje wykonywane po weryfikacji platno¶ci jesli wynik jest pozytywny
A to struktura tabeli
[MYSQL] pobierz, plaintext
[MYSQL] pobierz, plaintext


Dziekuje za chêci biggrin.gif

Ju¿ sobie poradzi³em z tym fantem  

Pozdro
To jest wersja lo-fi g³ównej zawarto¶ci. Aby zobaczyæ pe³n± wersjê z wiêksz± zawarto¶ci±, obrazkami i formatowaniem proszê kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.