problema mysql_data_seek

luigi777

Utente Attivo
14 Feb 2008
1.086
1
38
42
Massa, Italy
Salve, ho un problema con mysql_data_seek in un esempio che ho trovato su internet,

mi dite come posso risolvere questo Warning?

<b>Warning</b>: mysql_data_seek() [<a href='function.mysql-data-seek'>function.mysql-data-seek</a>]: Offset 3 is invalid for MySQL result index 5 (or the query data is unbuffered) in <b>D:\xampp\htdocs\directory\submitlink.php</b> on line <b>121</b><br />

e il suo codice che viene richiamato e cosi:
traverse(0,0,$selcat2);

codice:
PHP:
<?php
function traverse($root, $depth, $sql) 
{ 
     $row=0; 
     while ($acat = mysql_fetch_array($sql)) 
     { 
          if ($acat['CatParent'] == $root) 
          { 
               print "<option value='" . $acat['CatID'] . "'>"; 
               $j=0; 
               while ($j<$depth) 
               {     
                     print "&nbsp;&nbsp;";
                    $j++; 
               } 
               if($depth>0)
               {
                 print "-";
               }
               print $acat['CatName'] . "</option>"; 
               mysql_data_seek($sql,0); 
               traverse($acat['CatID'], $depth+1,$sql); 
                
          } 
          $row++; 
          mysql_data_seek($sql,$row); 
           
     } 
}

da errore qui : mysql_data_seek($sql,$row);

grazie mille.
 

Eliox

Utente Attivo
25 Feb 2005
4.390
3
0
cito dal manuale ufficile:
row_number starts at 0. The row_number should be a value in the range from 0 to mysql_num_rows() - 1. However if the result set is empty (mysql_num_rows() == 0), a seek to 0 will fail with a E_WARNING and mysql_data_seek() will return FALSE.
 

luigi777

Utente Attivo
14 Feb 2008
1.086
1
38
42
Massa, Italy

ciao, ho visto ma non risolvo nulla anche mettendo i controlli del manuale come dice ma mi da sempre i avvisi..

ti posto tutto il codice:
PHP:
<?php
include "connect.php";

session_start();
if(isset( $_SESSION['diradmin']))
{
  print "<table border='0' cellspacing='20'>";
  print "<tr><td valign='top'>";
  include "adminleft.php";
  print "</td>";
  print "<td valign='top'>";
  print "<table border='1' bordercolor='red'>";
  print "<tr><td bgcolor='red'><center><font color='white'>Add Link</font></center></td></tr>";
  print "<tr><td>";
  if(isset($_POST['submit']))
  {
    if(!$_POST['entry'])
    {
      print "You did not enter a Title";
    }
    else if(!$_POST['url']) 
    {
      print "You did not enter a URL";
    }
    else if (!$_POST['category'])
    {
      print "Please select a category";
    }
    else if(!$_POST['desc'])
    {
      print "Please input a description";
    }
    else //all required fields have been validated
    {
      if(!$_POST['rank'])
      {
        $rank=0;
      }
      else 
      {
        $rank=$_POST['rank'];
      }
      $entry=$_POST['entry'];
      $url=$_POST['url'];
      $category=$_POST['category'];
      $desc=$_POST['desc'];
      $insertentry="INSERT into cl_entries(EntryName, CatID,URL,Description,importance,validated) values('$entry','$category','$url','$desc','$rank','1')";
      mysql_query($insertentry) or die("Could not insert entry");
      print "Link Added Successfully";        

  }
 }
  else
  {
    print "<form action='addlink.php' method='post'>";
    print "Title of site:<br>";
    print "<input type='text' name='entry' size='20'><br>";
    print "URL(include http://)<br>";
    print "<input type='text' name='url' size='20'><br>";
    print "Category:<br>";
    $selcat="SELECT * from cl_categories order by CatName ASC";
    $selcat2=mysql_query($selcat) or die("Could not select category"); 
    print "<Select name='category'>";  
    
   traverse(0,0,$selcat2);
   
   

    print "</select>";  
    print "Importance(Zero is default, anything above zero is a sponsered listing)<br>";
    print "<input type='text' name='rank' size='5' value='0'><br>";
    print "Description:<br>";
    print "<textarea name='desc' rows='5' cols='40'></textarea><br>";
    print "<input type='submit' name='submit' value='submit'></form>";
  
  }
  print "</td></tr></table>";
  print "</td></tr></table>";
}
else
{
  print "Not logged in";
}

?>
<?php

function traverse($root, $depth, $sql) 
{ 
     $row=0; 
     while ($acat = mysql_fetch_assoc($sql)) 
     { 
          if ($acat['CatParent'] == $root) 
          { 
               print "<option value='" . $acat['CatID'] . "'>"; 
               $j=0; 
               while ($j<$depth) 
               {     
                     print "&nbsp;&nbsp;";
                    $j++; 
               } 
               if($depth>0)
               {
                 print "-";
               }
               print $acat['CatName'] . "</option>"; 
               mysql_data_seek($sql,0); 
               traverse($acat['CatID'], $depth+1,$sql); 
                
          } 
             $row++; 
		
		mysql_data_seek($sql,$row);   // QUESTA DA ERRORE.

  } 
} 
?>

Mi aiuti... poi dopo lo trovo convertire in Mysqli.

grazie mille.
 

Eliox

Utente Attivo
25 Feb 2005
4.390
3
0
Vedo

PHP:
mysql_data_seek($sql,$row)

se stampi a video il valore di $row cosa ti restituisce? Inserisci un controllo con mysql_error.
 

luigi777

Utente Attivo
14 Feb 2008
1.086
1
38
42
Massa, Italy
Scambia queste righe:
PHP:
             $row++;  
         
        mysql_data_seek($sql,$row);   // QUESTA DA ERRORE.
In questo modo:
PHP:
mysql_data_seek($sql, $row);
$row++;

nulla solito avviso .. e poi c'è una cosa che viene solamente scritto nel sorgente html invece a video non viene visualizzato ma solo quando io faccio "mostra sorgente pagina"...

boh!

non ci sto capendo più nulla.
comunque lo script è questo:
http://www.chipmunk-scripts.com/page.php?ID=15

grazie mille.
 

Eliox

Utente Attivo
25 Feb 2005
4.390
3
0
hai stampato a video il valore della variabile? Hai inserito il controllo con mysql_error()?
 
Discussioni simili
Autore Titolo Forum Risposte Data
S problema con recupero dati tabella mysql PHP 2
Z Problema con INT MySQL PHP 1
Z Problema database MySQL con XAMPP PHP 0
D problema php mysql PHP 1
D problema php mysql PHP 1
S Problema esportazione tabelle Mysql in Excel PHP 0
G Problema caricamento tabelle MySql da PhP PHP 0
Z MySQL problema Database 0
K [RISOLTO] Problema Griglia Php+Mysql PHP 13
elpirata [RISOLTO][Mysql] Problema insert valori apostrofati MySQL 1
V [MySQL] problema query con date su server MySQL 5
G inserimento csv in tabella mysql; problema con struttura PHP 11
S Problema ricevimento dati da con MySQL PHP 6
T PHP+MYSQL: problema con quelle maledette lettere accentate... PHP 5
batmanLF [MySQL] Problema funzione SUM MySQL 1
F Problema con mysql workbench MySQL 0
T Problema somma mysql MySQL 8
J [MySQL] Problema di sintassi? MySQL 1
M [MySql - VB6 sp6] Problema connessione db con alcuni pc (errore Lost connection to MySQL server...). MySQL 1
gandalf1959 problema con la codifica caratteri accentati e speciali tra php e mysql PHP 3
Q Problema su come far aggiornare i campi su un database Mysql PHP 17
webmachine [PHP][MYSQL] Problema con le SELECT PHP 5
F [MySQL] Problema con LEFT JOIN MySQL 6
G Mysql ( Query) problema interrogazione MySQL 0
simgia [MySQL] INNER JOIN problema MySQL 0
daniele430 [C++] Problema accenti - mysql - XML C/C++ 0
A [MySQL] problema con la command line client. MySQL 0
M Problema MySQL e sessioni MySQL 0
H problema input e echo più linee di una tabella mysql PHP 13
neo996sps PHP/MySQL - Problema con generazione array PHP 14
P Problema apostrofo su database MySQL... MySQL 0
M Problema connessione su OS X YOSEMITE 10.10 per il server locale mysql MySQL 0
M Problema connessione su OS X YOSEMITE 10.10 per il server locale mysql Mac e Software 0
G problema query mysql in php PHP 5
Emix Problema recupero Dati da MYSQL PHP 20
S Problema con pagination e mysql PHP 0
N Problema php e mysql PHP 2
F Problema selezione dinamica select/jsp/mysql Javascript 0
I Problema con DELETE - MYSQL PHP 6
StarFish [MySQL] Full Text problema rilevanza risultati MySQL 0
M problema con form scrittura su mysql PHP 3
B problema php e mysql PHP 3
O [risolto] Inserimento nuovo campo in mysql. Problema PHP 6
H Problema con MySQL e PHP, dopo aver fatto una SELECT non ottengo alcun risultato PHP 7
G Problema con query mysql MySQL 1
B problema query mysql php PHP 1
A problema con database (mysql - php) PHP 4
A problema con database (mysql - php) PHP 1
L PHP: problema con query mysql. PHP 3
V Problema str_replace MySql e caratteri accentati PHP 1

Discussioni simili