<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="http://forum.ubuntu-fr.org/extern.php?action=feed&amp;tid=1177021&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Forum Ubuntu-fr.org / connection BDD Mysql dans code C]]></title>
		<link>http://forum.ubuntu-fr.org/viewtopic.php?id=1177021</link>
		<description><![CDATA[Les sujets les plus récents dans connection BDD Mysql dans code C.]]></description>
		<lastBuildDate>Sun, 24 Feb 2013 20:52:30 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Réponse à&#160;:  connection BDD Mysql dans code C]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12697181#p12697181</link>
			<description><![CDATA[<p>désolé de ne plus avoir suivie le topic depuis plusieurs semaines (beaucoup de boulot) j&#039;ai recommence à zéro un code qui marche : </p><div class="codebox"><pre class="vscroll"><code>#include &lt;mysql.h&gt;
#include &lt;stdio.h&gt;

main() {
  MYSQL *conn;
  MYSQL_RES *res;
  MYSQL_ROW row;

  char *server = &quot;localhost&quot;;
  char *user = &quot;root&quot;;

  char *password = &quot;password&quot;; 
  char *database = &quot;composant_live&quot;;

  conn = mysql_init(NULL);


  if (!mysql_real_connect(conn, server,
        user, password, database, 0, NULL, 0)) {
      fprintf(stderr, &quot;%s\n&quot;, mysql_error(conn));

  }


  if (mysql_query(conn, &quot;SELECT etat FROM composant WHERE id LIKE &#039;1&#039;&quot;)) {
      fprintf(stderr, &quot;%s\n&quot;, mysql_error(conn));

  }

  res = mysql_use_result(conn);


  printf(&quot;Etat :\n&quot;);
  while ((row = mysql_fetch_row(res)) != NULL)
  printf(&quot;%s °C\n&quot;, row[0]);

char s_Mail[] = &quot;echo row[0] | mail -s \&quot;Rapport Journalier du système\&quot; destinatire@domaine.com -- -f expediteur@domaine.com&quot;;
        system(s_Mail);

  mysql_free_result(res);
  mysql_close(conn);
}</code></pre></div><p>le code trouve une valeur dans la bdd l&#039;affiche puis l&#039;envoie par mail, mais l&#039;ennuie c&#039;est que row[0] contient l&#039;information que je veux envoyer par mail, mais quand je met row[0] après echo pour l&#039;envoie du mail, le massage reçue par le destinataire affiche row[0] en clair mais pas sa valeur cela doit être un problème de variable comment faire ?&#160; </p><p>merci d&#039;avance</p>]]></description>
			<author><![CDATA[dummy@example.com (mauribilis)]]></author>
			<pubDate>Sun, 24 Feb 2013 20:52:30 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12697181#p12697181</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  connection BDD Mysql dans code C]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12368871#p12368871</link>
			<description><![CDATA[<div class="quotebox"><cite>mauribilis a écrit&#160;:</cite><blockquote><div><p>int etat_activee = &quot;etat_activee&quot;;</p></div></blockquote></div><p>Tu ne peux pas écrire une chaîne de caractères dans un &quot;int&quot;<br />En plus, tu ne t&#039;en sert pas par la suite : elle n&#039;est pas utilisée par ton sprintf.<br />Qu&#039;est-ce que tu veux obtenir, comme requête ?</p><p>(ne mélangeons pas, cette erreur là n&#039;a rien à voir avec les erreur de compilation &quot;undefined reference to `mysql_init&#039;&quot; etc.)</p>]]></description>
			<author><![CDATA[dummy@example.com (Melrock)]]></author>
			<pubDate>Mon, 28 Jan 2013 07:58:33 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12368871#p12368871</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  connection BDD Mysql dans code C]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12365241#p12365241</link>
			<description><![CDATA[<p>Et comme ci-dessous, ça donne quoi ?</p><div class="quotebox"><cite>mauribilis a écrit&#160;:</cite><blockquote><div><p>gcc -I/usr/include -L/usr/lib/mysql -o test_mysql&#160; test_mysql.c -lmysqlclient -lmysql</p></div></blockquote></div>]]></description>
			<author><![CDATA[dummy@example.com (eiger)]]></author>
			<pubDate>Sun, 27 Jan 2013 19:43:27 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12365241#p12365241</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  connection BDD Mysql dans code C]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12365031#p12365031</link>
			<description><![CDATA[<p>est ce que libmysqlclient.so est bien sous /usr/lib/mysql ?</p>]]></description>
			<author><![CDATA[dummy@example.com (telliam)]]></author>
			<pubDate>Sun, 27 Jan 2013 19:17:09 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12365031#p12365031</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  connection BDD Mysql dans code C]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12364441#p12364441</link>
			<description><![CDATA[<p>gcc -I/usr/include -lmysqlclient -lmysql -L/usr/lib/mysql -o test_mysql&#160; test_mysql.c</p>]]></description>
			<author><![CDATA[dummy@example.com (mauribilis)]]></author>
			<pubDate>Sun, 27 Jan 2013 18:28:10 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12364441#p12364441</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  connection BDD Mysql dans code C]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12351081#p12351081</link>
			<description><![CDATA[<p>Redonne la ligne de compilation stp?</p>]]></description>
			<author><![CDATA[dummy@example.com (telliam)]]></author>
			<pubDate>Sat, 26 Jan 2013 14:16:11 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12351081#p12351081</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  connection BDD Mysql dans code C]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12350621#p12350621</link>
			<description><![CDATA[<p>erreur : /tmp/cc8dj0sW.o: In function `main&#039;:<br />test_mysql.c:(.text+0x32): undefined reference to `mysql_init&#039;<br />test_mysql.c:(.text+0x4b): undefined reference to `mysql_options&#039;<br />test_mysql.c:(.text+0x91): undefined reference to `mysql_real_connect&#039;<br />test_mysql.c:(.text+0x104): undefined reference to `mysql_query&#039;<br />test_mysql.c:(.text+0x113): undefined reference to `mysql_close&#039;<br />collect2: ld a retourné 1 code d&#039;état d&#039;exécution</p><p>code :</p><div class="codebox"><pre class="vscroll"><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;time.h&gt;
#include &lt;mysql/mysql.h&gt;
 
 
 
int main(int argc, char **argv)
{
 
            //Déclaration de l&#039;objet de type MYSQL
            MYSQL mysql;
            //Initialisation de MySQL
            mysql_init(&amp;mysql);
            //Options de connexion
            mysql_options(&amp;mysql,MYSQL_READ_DEFAULT_GROUP,&quot;option&quot;);
char * etat_activee = &quot;etat_activee&quot;;


            //Si la connexion réussie...
            if(mysql_real_connect(&amp;mysql,&quot;localhost&quot;,&quot;root&quot;,&quot;password&quot;,&quot;composant_live&quot;,0,NULL,0))
            {
                //On déclare un tableau de char pour y stocker la requete
                char requete[150] = &quot;&quot;;
 
                //On stock la requete dans notre tableau de char
                sprintf(requete, &quot;INSERT INTO ballon VALUES(&#039;&#039;, &#039;1&#039;)&quot;, etat_activee);
 
 
                //On execute la requete
                mysql_query(&amp;mysql, requete);
 
 
                //Fermeture de MySQL
                mysql_close(&amp;mysql);
            }
            else
            {
                printf(&quot;Une erreur s&#039;est produite lors de la connexion a la BDD!&quot;);
            }
 
 
 
    return 0;
}</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (mauribilis)]]></author>
			<pubDate>Sat, 26 Jan 2013 13:22:11 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12350621#p12350621</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  connection BDD Mysql dans code C]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12332881#p12332881</link>
			<description><![CDATA[<div class="quotebox"><cite>mauribilis a écrit&#160;:</cite><blockquote><div><p>int etat_activee = &quot;etat_activee&quot;;</p></div></blockquote></div><p>il y a un pb dans ton code<br />avec cette ligne tu assignes a un entier une chaine de caracteres.</p>]]></description>
			<author><![CDATA[dummy@example.com (telliam)]]></author>
			<pubDate>Thu, 24 Jan 2013 20:20:21 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12332881#p12332881</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  connection BDD Mysql dans code C]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12332801#p12332801</link>
			<description><![CDATA[<p>erreur toujours pareil en ayant viré -lmysql</p>]]></description>
			<author><![CDATA[dummy@example.com (mauribilis)]]></author>
			<pubDate>Thu, 24 Jan 2013 20:14:54 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12332801#p12332801</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  connection BDD Mysql dans code C]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12332791#p12332791</link>
			<description><![CDATA[<p>int etat_activee = &quot;etat_activee&quot;;</p>]]></description>
			<author><![CDATA[dummy@example.com (mauribilis)]]></author>
			<pubDate>Thu, 24 Jan 2013 20:14:06 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12332791#p12332791</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  connection BDD Mysql dans code C]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12332741#p12332741</link>
			<description><![CDATA[<p>vire le -lmysql<br />c quoi la ligne de code a la ligne 17?</p>]]></description>
			<author><![CDATA[dummy@example.com (telliam)]]></author>
			<pubDate>Thu, 24 Jan 2013 20:08:53 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12332741#p12332741</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  connection BDD Mysql dans code C]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12332231#p12332231</link>
			<description><![CDATA[<p>test_mysql.c: In function ‘main’:<br />test_mysql.c:17:26: attention : initialization makes integer from pointer without a cast [enabled by default]<br />/usr/bin/ld: cannot find -lmysql<br />collect2: ld a retourné 1 code d&#039;état d&#039;exécution</p>]]></description>
			<author><![CDATA[dummy@example.com (mauribilis)]]></author>
			<pubDate>Thu, 24 Jan 2013 19:34:51 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12332231#p12332231</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  connection BDD Mysql dans code C]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12331821#p12331821</link>
			<description><![CDATA[<p>rajoute : -L/usr/lib/mysql</p>]]></description>
			<author><![CDATA[dummy@example.com (telliam)]]></author>
			<pubDate>Thu, 24 Jan 2013 19:05:58 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12331821#p12331821</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  connection BDD Mysql dans code C]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12330891#p12330891</link>
			<description><![CDATA[<p>gcc -I/usr/include -lmysqlclient -lmysql -o test_mysql&#160; test_mysql.c</p><p>erreur :</p><p>test_mysql.c: In function ‘main’:<br />test_mysql.c:17:26: attention : initialization makes integer from pointer without a cast [enabled by default]<br />/usr/bin/ld: cannot find -lmysql<br />collect2: ld a retourné 1 code d&#039;état d&#039;exécution</p>]]></description>
			<author><![CDATA[dummy@example.com (mauribilis)]]></author>
			<pubDate>Thu, 24 Jan 2013 18:11:52 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12330891#p12330891</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  connection BDD Mysql dans code C]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12330241#p12330241</link>
			<description><![CDATA[<p>rajoute -lmysql</p>]]></description>
			<author><![CDATA[dummy@example.com (telliam)]]></author>
			<pubDate>Thu, 24 Jan 2013 17:42:13 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12330241#p12330241</guid>
		</item>
	</channel>
</rss>
