Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL] redeclale safe ()
edwarpan
post
Post #1





Grupa: Zarejestrowani
Postów: 66
Pomógł: 0
Dołączył: 28.04.2010

Ostrzeżenie: (0%)
-----


Witam, znów problem.
  1.  
  2. function safe($input) {
  3.  
  4. $valid_input = mysql_escape_string($input);
  5.  
  6. return $valid_input;
  7.  
  8. }
  9.  
  10. ?>


Jest to kawałek, w tym który podałem wyskakuję błąd:

  1. Fatal error: Cannot redeclare safe() (previously declared in /home/mentos/domains/x.pl/public_html/config.php:50) in /home/mentos/domains/x.pl/public_html/config.php on line 56


Po dopisaniu
mysql_error
W 1 linijce podanej:
  1. Parse error: syntax error, unexpected T_LOGICAL_OR, expecting

A w 2 linijce
  1. Parse error: syntax error, unexpected T_STRING in




Bez mysql error
Cannot redeclare safe() (previously declared in /home/mentos/domains/panel.lockerz.e-zdunek.pl/public_html/config.php:50) in xxxx.pl on line 56

W w 56 linii jest klamra }

Ten post edytował edwarpan 7.05.2010, 08:03:11
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 5)
piotrooo89
post
Post #2


Newsman


Grupa: Moderatorzy
Postów: 4 005
Pomógł: 548
Dołączył: 7.04.2008
Skąd: Trzebinia/Kraków




masz już gdzieś wcześniej zadeklarowaną funkcję o tej samej nazwie safe.
Go to the top of the page
+Quote Post
edwarpan
post
Post #3





Grupa: Zarejestrowani
Postów: 66
Pomógł: 0
Dołączył: 28.04.2010

Ostrzeżenie: (0%)
-----


Niby jest, lecz służy do zapamiętywania sesji?
  1. <?php
  2. $host = "localhost";
  3.  
  4. $db_username = "x"; // Your database username
  5.  
  6. $db_pass = "x"; // the password to your username
  7.  
  8. $db_name = "x"; // the name of the database your 'users' table is in.
  9.  
  10. $connection = mysql_connect("$host","$db_username","$db_pass") or die ("Couldn't connect to server.");
  11.  
  12. $db = mysql_select_db("$db_name", $connection) or die("Couldn't select database.");
  13.  
  14. error_reporting (E_ALL ^ E_NOTICE);
  15.  
  16. $salt = "ZKd88lUhsk21"; // creates a salt value to better encrypt the users password
  17.  
  18. $mysql = mysql_query("SELECT * FROM users WHERE username='".safe($_COOKIE['username'])."' AND id='".safe($_COOKIE['id'])."' AND password='".safe($_COOKIE['password'])."'");
  19.  
  20. $row = mysql_fetch_array($mysql);
  21.  
  22. $registration_date = $row['regdate'];
  23.  
  24. $email = $row['email'];
  25.  
  26. $tele = $row['tele'];
  27.  
  28. $gg = $row['gg'];
  29.  
  30. $show_email = $row['show_email'];
  31.  
  32.  
  33.  
  34. $mysql = mysql_query("SELECT * FROM users WHERE username='".safe($_COOKIE['username'])."' AND id='".safe($_COOKIE['id'])."' AND password='".safe($_COOKIE['password'])."'");
  35.  
  36. $rows = mysql_num_rows($mysql);
  37.  
  38. if($rows != 1) {
  39.  
  40. $logged_in = 0;
  41.  
  42. } else {
  43.  
  44. $logged_in = 1;
  45.  
  46. }
  47.  
  48.  
  49. function safe ($input) {
  50.  
  51. $valid_input = mysql_escape_string($input);
  52.  
  53. return $valid_input;
  54.  
  55. }
  56.  
  57. ?>
Go to the top of the page
+Quote Post
piotrooo89
post
Post #4


Newsman


Grupa: Moderatorzy
Postów: 4 005
Pomógł: 548
Dołączył: 7.04.2008
Skąd: Trzebinia/Kraków




na pewno nie includujesz jakiegoś pliku w którym masz zadeklarowaną tą funkcję?
Go to the top of the page
+Quote Post
phpion
post
Post #5





Grupa: Moderatorzy
Postów: 6 072
Pomógł: 861
Dołączył: 10.12.2003
Skąd: Dąbrowa Górnicza




Jeśli nie chcesz za dużo kombinować to wrzuć deklarację funkcji w warunek ze sprawdzeniem, czy funkcja przypadkiem nie została już zadeklarowana (function_exists).
Go to the top of the page
+Quote Post
edwarpan
post
Post #6





Grupa: Zarejestrowani
Postów: 66
Pomógł: 0
Dołączył: 28.04.2010

Ostrzeżenie: (0%)
-----


Dzięki, nie wiem po co do logowania includowałem.

Do zamknięcia!
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 3.10.2025 - 19:50