• User Newbie

    MD Glossary

    Ciao ragazzi, avrei bisogno di aiuto da parte vostra.

    Sto cercando di creare un Glossario, utilizzando lo script MD Glossary, sul mio nuovo spazio web. Premettendo che in passato ne avevo già uno (ma su 1 altro host, che purtroppo mi hanno chiuso) sto eseguendo la stessa procedura dell'altra volta, ma qualcosa non va. Del programma mi ero tenuto un file.zip con i files principali (l'originale), e dopo aver settato nel config i dati del nuovo db mysql mi da un errore imprevisto:
    "*Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in **/home/mhd-01/XXXXXXXXXXX/htdocs/cosmo/admin.php **on line *280"

    A questo punto sono andato a controllare la parte in questione.

    //Main menu
    if($action=="main"||!$action)
    {
    echo "<a href="$PHP_SELF?action=add">Add a word</a>   <a href="$PHP_SELF?action=help">Help</a><br><br>";
    $getWords=mysql_query("SELECT * FROM mdglossary ORDER BY word");
    if($getWordArray=mysql_fetch_array($getWords))
    {
    echo "<table width="90%" cellspacing="8" cellpadding="0">";
    do
    {
    echo "

    Script completo

    <?php

    echo "<i>Version 1.0.0</i><br><br>";
    $configfile = "config.php";
    require $configfile;
    $db = mysql_connect("$host", "$username", "$password");
    mysql_select_db("$databasename", $db);

    //Add word
    if($action=="add")
    {
    if($word&&$definition)
    {
    $addWord=mysql_query("INSERT INTO mdglossary (word, definition) VALUES ('$word', '$definition')", $db);
    if($addWord)
    {
    echo "The word $word and it's definition has been successfully added to the database";
    }
    if(!$addWord)
    {
    echo "There has been an error in adding the word $word";
    }
    }
    if(!$word||!$definition)
    {
    echo "
    <form name="mdglossary" action="$PHP_SELF" method="post">
    <b>Word</b>
    <br>
    <i>The word you want adding</i>
    <br>
    <input name="word" type="text" value="" maxlength="40">
    <br>
    <br>
    <b>Definition</b>
    <br>
    <i>The definition of the word</i>
    <br>
    <textarea name="definition" rows="6" cols="50" ></textarea>
    <br>
    <input name="action" type="hidden" value="add">
    <input type="submit" value="Add">    <input type="reset" value="Reset">
    </form>
    ";
    }
    }

    //Edit word
    if($action=="edit")
    {
    if($word&&$definition)
    {
    $updateIt=mysql_query("UPDATE mdglossary SET word='$word', definition='$definition' WHERE id='$id'",$db);
    if($updateIt)
    {
    echo "The word $word has been successfully updated";
    }
    if(!$updateIt)
    {
    echo "There has been an error in updating the word $word";
    }
    }
    if(!$word&&!$defintion)
    {
    $getInfo=mysql_query("SELECT * FROM mdglossary WHERE id=$id",$db);
    if($theInfo=mysql_fetch_array($getInfo))
    {
    echo "
    <form name="mdglossary" action="$PHP_SELF" method="post">
    <b>Word</b>
    <br>
    <i>The word you want editing</i>
    <br>
    <input name="word" type="text" value="";
    printf($theInfo["word"]);
    echo "" maxlength="40">
    <br>
    <br>
    <b>Definition</b>
    <br>
    <i>The definition of the word</i>
    <br>
    <textarea name="definition" rows="6" cols="50" >";
    printf($theInfo["definition"]);
    echo "</textarea>
    <br>
    <input name="action" type="hidden" value="edit">
    <input name="id" type="hidden" value="$id">
    <input type="submit" value="Update">    <input type="reset" value="Reset">
    </form>
    ";
    }
    else
    {
    echo "There has been an error";
    }
    }
    }

    //Delete word
    if($action=="delete")
    {
    if($check=="yes")
    {
    $deleteIt=mysql_query("DELETE FROM mdglossary WHERE id=$id",$db);
    if($deleteIt)
    {
    echo "The word has successfully been deleted";
    }
    if(!$deleteIt)
    {
    echo "There has been an error whilst the word was being deleted. Please try again";
    }
    }
    else
    {
    $getDeleteInfo=mysql_query("SELECT * FROM mdglossary WHERE id='$id'",$db);
    $deleteInfo=mysql_fetch_array($getDeleteInfo);
    echo "Are you sure you want to delete the following word?<br>";
    echo "
    <dl>
    <dt><b>
    ";
    printf($deleteInfo["word"]);
    echo "
    </b></dt>
    <dd>
    ";
    printf($deleteInfo["definition"]);
    echo "
    </dd>
    </dl>
    ";
    echo "<br><a href="$PHP_SELF?action=delete&id=$id&check=yes">Yes</a>   <a href="$PHP_SELF?action=main">No</a>";
    }
    }

    //Get Code
    if($action=="getcode")
    {
    $getInfo=mysql_query("SELECT * FROM mdglossary WHERE id=$id",$db);
    if($getCode=mysql_fetch_array($getInfo))
    {
    $lowWord=strtolower($getCode["word"]);
    echo "The code that you can copy and paste the word - <b>";
    printf($getCode["word"]);
    echo "</b> - into your pages is:<br><br>";
    echo "<form><textarea cols="50" rows="5">";
    echo "<a href="$roottoglossary?word=$lowWord" class="glossary" title="Click here to find out what this word means">";
    printf($getCode["word"]);
    echo "</a>";
    echo "</textarea></form>";
    echo "Example:<br><br><a href="$roottoglossary?word=$lowWord" class="glossary" title="Click here to find out what this word means">";
    printf($getCode["word"]);
    echo "</a>";
    }
    else
    {
    echo "Sorry, there has been an error";
    }
    }

    //Install
    if($action=="install")
    {
    $createDb=mysql_query("CREATE TABLE mdglossary (
    id int(6) NOT NULL auto_increment,
    word varchar(40) default NULL,
    definition text,
    PRIMARY KEY (id),
    UNIQUE KEY id (id),
    FULLTEXT KEY word (word,definition)
    )
    ");
    if($createDb)
    {
    echo "MD Glossary has been installed successfully on your server";
    }
    else
    {
    echo "There has been a problem in installing MD Glossary";
    }
    }

    //Add wordpack
    if($action=="addwordpack")
    {
    if($packname)
    {
    echo "Include file:<br>";
    if(include ($packname))
    {

    $insertPack=mysql_query($insertLines);

    if($insertPack)
    {
    echo "the pack has been added successfully<br>";
    }
    else
    {
    echo "Sorry there has been an error<br>";
    }
    }
    else
    {
    echo "Sorry, there has been a problem opening $packname. Check that you have uploaded it correctly and that you have typed in the name correctly.";
    echo "
    <br>
    <form name="pack" action="$PHP_SELF" method="get">
    <input name="packname" type="text" value="">
    <input name="action" type="hidden" value="addwordpack">
    <br>
    <input type="submit" value="Add">
    </form>
    ";
    }
    $rep = "<br>(";
    $insertLines = ereg_replace("(", $rep, $insertLines);
    echo $insertLines;
    }
    else
    {
    echo "Type in the filename of the wordpack you want to add. (ie <i>internetpack.php</i>)";
    echo "
    <br>
    <form name="pack" action="$PHP_SELF" method="get">
    <input name="packname" type="text" value="">
    <input name="action" type="hidden" value="addwordpack">
    <br>
    <input type="submit" value="Add">
    </form>
    ";
    }
    }

    //Help
    if($action=="help")
    {
    echo "For up-to-date help, information and upgrades to MD Glossary, as well as other new programs to use on your website, visit <a href="matthewdingley.co.uk/programs/glossary/" target="_blank">MD Web</a>";
    }

    //Main menu
    if($action=="main"||!$action)
    {
    echo "<a href="$PHP_SELF?action=add">Add a word</a>   <a href="$PHP_SELF?action=help">Help</a><br><br>";
    $getWords=mysql_query("SELECT * FROM mdglossary ORDER BY word");
    if($getWordArray=mysql_fetch_array($getWords))
    {
    echo "<table width="90%" cellspacing="8" cellpadding="0">";
    do
    {
    echo "
    <tr>
    <td>
    <dl>
    <dt><b>
    ";
    printf($getWordArray["word"]);
    echo "
    </b></dt>
    <dd>
    ";
    printf($getWordArray["definition"]);
    echo "
    </dd>
    </dl>
    </td>

           <td>
           <a href=\"$PHP_SELF?action=edit&id=";
    

    printf($getWordArray["id"]);
    echo "
    ">Edit</a>
    </td>

           <td>
           <a href=\"$PHP_SELF?action=delete&id=";
    

    printf($getWordArray["id"]);
    echo "
    ">Delete</a>
    </td>
    <td>
    <a href="$PHP_SELF?action=getcode&id=";
    printf($getWordArray["id"]);
    echo "
    ">Get code</a>
    </td>
    </tr>
    ";
    }
    while($getWordArray=mysql_fetch_array($getWords));
    echo "</table>";
    }
    else
    {
    echo "<br><br>There are currently no words in the database. <a href="$PHP_SELF?action=add">Add a word</a>";
    }
    }
    if($action=="add"||$action=="edit"||$action=="delete"||$action=="getcode"||$action=="install"||$action=="addwordpack"||$action=="help")
    {
    echo "<br><br><a href="$PHP_SELF?action=main">Main menu</a>     <a href="$PHP_SELF?action=add">Add a word</a>     <a href="$PHP_SELF?action=help">Help</a>";
    }
    ?>

    Non so più che pesci pigliare :arrabbiato:
    Mi dareste una mano?


  • ModSenior

    Evidenzi la riga che da l'errore?
    comunque è la query a cui fa riferimento che genera un errore, aggiungi a quella query or die(mysql_error()) e vedi che errore restituisce


  • User Newbie

    è questa**

    if($getWordArray=mysql_fetch_array($getWords))**


  • ModSenior

    $getWords=mysql_query("SELECT * FROM mdglossary ORDER BY word") or die(mysql_error());

    vedi se restituisce un errore la query


  • User Newbie

    Allora, con la soluzione qui sopra scompare il problema per cui ho chiesto aiuto, ma al momento di avviare l'installazione, ancora una volta non me lo fa fare poiché dice **'saintsei95518.mdglossary' doesn't exist

    **Con la soluzione inviata nel pm, invece, mi esce il solito errore

    "*Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in **/home/mhd-01/XXXXXXXXXXX/htdocs/cosmo/admin.php **on line *280"


  • ModSenior

    Col metodo qui sopra dovrebbe invece dirti l'errore... nn scomparire

    se hai fatto la modifica che ti ho inviato in pm nella riga 280 nn c'è mysql_fetch_array e quindi non può darti quell'errore


  • User Newbie

    Errore mio, esce**

    Warning**: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mhd-01/XXXXXXXX/htdocs/cosmo/admin.php on line 280


  • User Newbie

    Grazie a Thedarkita il problema è stato risolto!