İyinet'e Hoşgeldiniz!

Türkiye'nin En Eski Webmaster Forum'una Hemen Kayıt Olun!

Kayıt Ol!

php ve mysql ile ilgili ...

worshiphim

0
İyinet Üyesi
Katılım
16 Ocak 2005
Mesajlar
670
Reaction score
0
Konum
Suisse
merhaba aşağıdaki kod ile hata alıyorum acaba nerede sorun var deliricem yardım edene teşekkürler şimdiden

<?php
$dbh=mysql_connect ("localhost", "myworld", "") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("myworld");

$result = mysql_query("SELECT comments, kategori, kategori2, pictures, users, yorumlar FROM myworld");

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
printf("ID: %s Name: %s", $row[0], $row[1], );
}

mysql_free_result($result);
?>

aşağıdaki hatalrı veriyor:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/myw/public_html/eris.php on line 7

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/myw/public_html/eris.php on line 11


amacım veri tabanındaki herşeyi listelemekti :confused:
 

iyinet

Root
Admin
Hosting Firması
Katılım
2 Eylül 2002
Mesajlar
5,030
Reaction score
73
Konum
Sakarya
Bu hata
$result = mysql_query("SELECT comments, kategori, kategori2, pictures, users, yorumlar FROM myworld");
satirinda hata oldugu anlamina geliyor.
Sanirim sorguda hata var, ornegin yanlis kolon ismi gibi...
Satiri su sekilde degistirirsen daha genis bir hata mesaji alabilirsin.
$result = mysql_query("SELECT comments, kategori, kategori2, pictures, users, yorumlar FROM myworld") or die(mysql_error());
 

iyinet

Root
Admin
Hosting Firması
Katılım
2 Eylül 2002
Mesajlar
5,030
Reaction score
73
Konum
Sakarya
worshiphim' Alıntı:
amacım veri tabanındaki herşeyi listelemekti :confused:
Eger senin "hersey" dedigin tablolar ise su sekilde bir sorgu yapabilirsin:
PHP:
$result = mysql_query("show tables");
"select" sorgusunu tablolar uzerinde yapman gerekiyor, veritabani uzerinde degil!
 
F

FreeBSD

Misafir
PHP:
<?php
$connb = mysql_connect("localhost","root","")or die("Hata: ". $mysql_error());
mysql_select_db("eb2b", $connb)or die("Hata: ". $mysql_error());
$query = mysql_query("Select * from products");
while($mysql_bilgi = mysql_fetch_object($query)) {
$pname = stripslashes($mysql_bilgi->pname);
$pord = stripslashes($mysql_bilgi->pord);
   echo "Urun Adı: ". $pname . "<br> Urun Fiyatı: " . $pord . "";
}
mysql_close($connb);
?>
 

iyinet

Root
Admin
Hosting Firması
Katılım
2 Eylül 2002
Mesajlar
5,030
Reaction score
73
Konum
Sakarya
FreeBSD' Alıntı:
PHP:
<?php
$connb = mysql_connect("localhost","root","")or die("Hata: ". $mysql_error());
mysql_select_db("eb2b", $connb)or die("Hata: ". $mysql_error());
$query = mysql_query("Select * from products");
while($mysql_bilgi = mysql_fetch_object($query)) {
$pname = stripslashes($mysql_bilgi->pname);
$pord = stripslashes($mysql_bilgi->pord);
   echo "Urun Adı: ". $pname . "<br> Urun Fiyatı: " . $pord . "";
}
mysql_close($connb);
?>

Veritabanindan okurken stripslashes yapmaya gerek yok.
Sadece veritabanina yazarken addslashes yapmaniz yeterli.
 
F

FreeBSD

Misafir
Kullandığı editor'e göre error satırları değişebilir...

Mesela pla'da yazdığın bir script'de Line 10 diyorsa bu error illa da Line 10'da demek değildir...
 
F

FreeBSD

Misafir
Okurken de yapmanda fayda var...

+ Bu, arkadaşın dikkatini çekmesi için yaptığım birşey...

Yani biraz araştırsa bulabilir...
 

iyinet

Root
Admin
Hosting Firması
Katılım
2 Eylül 2002
Mesajlar
5,030
Reaction score
73
Konum
Sakarya
FreeBSD' Alıntı:
Okurken de yapmanda fayda var...

+ Bu, arkadaşın dikkatini çekmesi için yaptığım birşey...

Yani biraz araştırsa bulabilir...

stripslash i veritabanindan okurken kullanmanin zararlari asagida aciklaniyor.

Asagidaki aciklamalar php.net sitesinden alinmistir:
Kaynak link: http://us4.php.net/manual/en/function.addslashes.php
---------------------------------------------------------------
gv
06-Nov-2004 06:23
Regarding the previous note using addslashes/stripslahes with regular expressions and databases it looks as if the purpose of these functions gets mixed.

addslahes encodes data to be sent to a database or something similar. Here you need addslashes because you send commands to the database as command strings that contain data and thus you have to escape characters that are special in the command language like SQL.

Therefore the use of addslahses on a regex does properly store the regex in the database.

stripslashes does the opposite: it decodes an addslashes encoded string. However, retrieving data from a database works differently: it does not go through some string interpretation because you actually retrieve your binary data in your variables. In other words: the data stored in your variable is the unmodified binary data that your database returned. You do not run stripslahes on data returned from a database. That way, the regexs are retrieved correctly, too.

This is different from other data exchange like urlencoded strings that you exchange with your browser. Here the data channel uses the same encodings in both directions: therefore you have to encode data to be sent and you have to decode data received.
---------------------------------------------------------------
 
F

FreeBSD

Misafir
iyinetadmin: tartışmaya gerek yok...

stripslashes'i kullanmanın zararları olduğu kadar yararları da vardır...
 

Türkiye’nin ilk webmaster forum sitesi iyinet.com'da forum üyeleri tarafından yapılan tüm paylaşımlardan; Türk Ceza Kanunu’nun 20. Maddesinin, 5651 Sayılı Kanununun 4. maddesinin 2. fıkrasına göre, paylaşım yapan üyeler sorumludur.

Üst