<br><br><div class="gmail_quote">Il giorno 13 gennaio 2011 19:14, Mirko <span dir="ltr">&lt;<a href="mailto:mirkos93@gmail.com">mirkos93@gmail.com</a>&gt;</span> ha scritto:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Prova:<br>
print_r($res);<br>
print_r(mysql_affected_rows());<br>
<br>
(Quindi prova a non dare argomenti a mysql_affected_rows ed usare print_r)<br>
Mirko<br>
<br>
Il 13 gennaio 2011 19:11, Davide &quot;DeMoN3&quot; Angelini<br>
<div><div></div><div class="h5">&lt;<a href="mailto:demon3rock@gmail.com">demon3rock@gmail.com</a>&gt; ha scritto:<br>
&gt; Il giorno 13 gennaio 2011 18:59, Mirko &lt;<a href="mailto:mirkos93@gmail.com">mirkos93@gmail.com</a>&gt; ha scritto:<br>
&gt;&gt;<br>
&gt;&gt; Ciao Davide,<br>
&gt;&gt; non ho ben capito cosa devi fare, puoi spiegare meglio?<br>
&gt;&gt; Il tuo codice è:<br>
&gt;&gt; $res = &quot;update utenti set account=&#39;ciao&#39;;<br>
&gt;&gt; $res = mysql_query($res);<br>
&gt;&gt; print_r(mysql_affected_rows($res));<br>
&gt;&gt; ????<br>
&gt;&gt; Se è così, perché questa ripetizioni di variabili?<br>
&gt;&gt; Mirko<br>
&gt;&gt;<br>
&gt;&gt; Il 13 gennaio 2011 18:26, Davide &quot;DeMoN3&quot; Angelini<br>
&gt;&gt; &lt;<a href="mailto:demon3rock@gmail.com">demon3rock@gmail.com</a>&gt; ha scritto:<br>
&gt;&gt; &gt; Ragazzi, ho un problemino con mysql usato con php.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Praticamente faccio una semplicissima query di update, oserei dire<br>
&gt;&gt; &gt; banale.<br>
&gt;&gt; &gt; update utenti set account=&#39;ciao&#39;<br>
&gt;&gt; &gt; e la mando in esecuzione con $res=mysql_query($res).<br>
&gt;&gt; &gt; Il problema è che $res, dopo questa operazione, vale 1 o_O<br>
&gt;&gt; &gt; e se lo passo a mysql_affected_rows($res) mi dice<br>
&gt;&gt; &gt; Warning: mysql_affected_rows(): supplied argument is not a valid<br>
&gt;&gt; &gt; MySQL-Link<br>
&gt;&gt; &gt; resource<br>
&gt;&gt; &gt; guardando il DB, però, le modifiche sono state fatte...  (posso anche<br>
&gt;&gt; &gt; fare<br>
&gt;&gt; &gt; in modo che modifichi + righe di codice e el modifica tutte, ma sempre 1<br>
&gt;&gt; &gt; vale).<br>
&gt;&gt; &gt; Non sò più dove sbattere la testa...faccio io qualche cazzata di cui non<br>
&gt;&gt; &gt; mi<br>
&gt;&gt; &gt; rendo conto?<br>
&gt;&gt; &gt; --<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Davide Angelini<br>
&gt;&gt; &gt;<br>
&gt;<br>
&gt; $query=&quot;update tabella set campo=&#39;valore&#39; where id=&#39;100&#39;&quot;;<br>
&gt;<br>
&gt; poi la eseguo<br>
&gt;<br>
&gt; $res=mysql_query($query);<br>
&gt;<br>
&gt; fino a qui tutto normale, la query viene eseguita e i valori sul DB cambiano<br>
&gt; (quindi la connessione c&#39;è)<br>
&gt;<br>
&gt; ora, per vedere se la query è andata a buon fine, faccio un<br>
&gt;<br>
&gt; if($res)<br>
&gt; {<br>
&gt; [istruzioni]<br>
&gt; }<br>
&gt;<br>
&gt; che però si comporta in modo anomalo.<br>
&gt;<br>
&gt; Andando a scavare un pò,<br>
&gt; ho fatto un<br>
&gt;<br>
&gt; echo $res;<br>
&gt;<br>
&gt; e questo mi restituisce sempre e comunque 1 o_O<br>
&gt;<br>
&gt; poi faccio un<br>
&gt;<br>
&gt; echo mysql_affected_rows($res);<br>
&gt;<br>
&gt; ma il php mi avverte con<br>
&gt;<br>
&gt; Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link<br>
&gt; resource<br>
&gt;<br>
&gt; e anche se la query va male (ad esempio mettendo un id inesistente), $res è<br>
&gt; sempre sempre sempre =1<br>
&gt;<br>
&gt; ci sto diventando scemo, mysql_query, associata all&#39;update, dovrebbe<br>
&gt; restituire true o false a seconda se va bene o male e tramite<br>
&gt; mysql_affected_rows dovrebbe dirmi quante righe son state modificate o_O<br>
&gt; For other type of SQL statements, INSERT, UPDATE, DELETE, DROP,<br>
&gt; etc, mysql_query() returns TRUE on success or FALSE on error.<br>
&gt; Use mysql_affected_rows() to find out how many rows were affected by a<br>
&gt; DELETE, INSERT, REPLACE, or UPDATE statement<br>
&gt; In realtà faccio tutto annidato per non usare variabili inutili, era solo a<br>
&gt; &quot;scopo chiarificatore&quot;.<br>
&gt; Il problema, comunque, non è la qualità del codice, ma il fatto che proprio<br>
&gt; non funziona o_O<br>
&gt; o mi son rincojonito io e devo andare in ferie?!?<br>
&gt;<br>
&gt; --<br>
&gt;<br>
&gt;<br>
&gt; Davide Angelini<br>
&gt;<br>
</div></div><div><div></div><div class="h5">&gt; _______________________________________________<br>
&gt; <a href="http://www.llg.it" target="_blank">http://www.llg.it</a><br>
&gt; latina mailing list<br>
&gt; <a href="mailto:latina@lists.linux.it">latina@lists.linux.it</a><br>
&gt; <a href="http://lists.linux.it/listinfo/latina" target="_blank">http://lists.linux.it/listinfo/latina</a><br>
&gt;<br>
&gt;<br>
<br>
<br>
<br>
--<br>
<a href="http://www.mirkoweb.org" target="_blank">http://www.mirkoweb.org</a> | <a href="http://blog.mirkoweb.org" target="_blank">http://blog.mirkoweb.org</a><br>
_______________________________________________<br>
<a href="http://www.llg.it" target="_blank">http://www.llg.it</a><br>
latina mailing list<br>
<a href="mailto:latina@lists.linux.it">latina@lists.linux.it</a><br>
<a href="http://lists.linux.it/listinfo/latina" target="_blank">http://lists.linux.it/listinfo/latina</a><br>
</div></div></blockquote></div><br>...ok...così funziona...ma non passandogli argomenti non vorrei che usasse un link sbagliato...e poi perchè passandoglielo scazza? <span class="Apple-style-span" style="font-family: verdana, arial, helvetica, sans-serif; font-size: 14px; border-collapse: collapse; "><span class="type">int</span> <span class="methodname"><b>mysql_num_rows</b></span> ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter" style="font-family: Consolas, &#39;Andale Mono WT&#39;, &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, &#39;Courier New&#39;, Courier, monospace; font-style: italic; ">$result</tt></span> )</span><br clear="all">

<br>-- <br><br><br>Davide Angelini<br>