<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Piccolo problema...]]></title><description><![CDATA[<p dir="auto">Buongiorno a tutti<br />
ho questo pezzo di codice per aggiungere certi valori su un DB Mysql:</p>
<pre><code>&lt;?php
 // creates the new record form
 // since this form is used multiple times in this file, I have made it a function that is easily reusable
 function renderForm($apiario, $lat, $long, $error)
 {
 ?&gt;
&lt;!DOCTYPE html&gt;
&lt;head&gt;
	&lt;meta charset="utf-8" /&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class="container"&gt;
			&lt;div class="eight columns"&gt;
				&lt;h3&gt;Elenco degli apiari&lt;/h3&gt;
				&lt;div class="row"&gt;
					&lt;div class="twelve columns"&gt;
						&lt;div class="panel"&gt;
 &lt;?php 
 // if there are any errors, display them
 if ($error != '')
 {
 echo '&lt;div style="padding:4px; border:1px solid red; color:red;"&gt;'.$error.'&lt;/div&gt;';
 }
 ?&gt; 
 
 &lt;form action="" method="post"&gt;
 &lt;div&gt;
 &lt;label&gt;Nome Apiario: *&lt;/label&gt; &lt;input type="text" class="input-text" name="apiario" value="&lt;?php echo $apiario; ?&gt;" /&gt;&lt;br/&gt;

 &lt;label&gt;Latitudine: *&lt;/label&gt; &lt;input type="text" class="input-text" name="lat" value="&lt;?php echo $lat; ?&gt;" /&gt;&lt;br/&gt;&lt;br&gt;

 &lt;label&gt;Longitudine: *&lt;/label&gt; &lt;input type="text" class="input-text" name="long" value="&lt;?php echo $long; ?&gt;" /&gt;&lt;br/&gt;&lt;br&gt;
 
 &lt;p&gt;* campi obbligatori&lt;/p&gt;
 &lt;input type="submit" name="submit" value="Registra" class="nice radius blue button"&gt;
 &lt;/div&gt;
 &lt;/form&gt; 
&lt;/div&gt;&lt;/div&gt;
 &lt;!-- Included JS Files --&gt;
	&lt;script src="javascripts/foundation.js"&gt;&lt;/script&gt;
	&lt;script src="javascripts/app.js"&gt;&lt;/script&gt;
 &lt;/body&gt;
 &lt;/html&gt;  
 &lt;?php 
 }
  // connect to the database
 include('connect-db.php');
 
 // check if the form has been submitted. If it has, start to process the form and save it to the database
 if (isset($_POST['submit']))
 { 
 // get form data, making sure it is valid
 $apiario = mysql_real_escape_string(htmlspecialchars($_POST['apiario']));
 $lat = mysql_real_escape_string(htmlspecialchars($_POST['lat']));
 $long = mysql_real_escape_string(htmlspecialchars($_POST['long']));

 // check to make sure both fields are entered
 if ($apiario == '' || $lat == '' || $long == '')
 {
 // generate error message
 $error = '* Riempire i campi obbligatori';
 
 // if either field is blank, display the form again
 renderForm($apiario, $lat, $long, $error);
 }
 else
 {
 // save the data to the database
 mysql_query("INSERT apiari SET apiario='$apiario', lat='$lat', long='$long'")
 or die(mysql_error()); 
 
 // once saved, redirect back to the view page
 header("Location: index.php"); 
 }
 }
 else
 // if the form hasn't been submitted, display the form
 {
 renderForm('','','','');
 }
?&gt;
</code></pre>
<p dir="auto">Ho ricontrollato mille volte il codice ma ricevo questo errore:<br />
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'long='testo di prova'' at line 1</p>
<p dir="auto">Non so più che pesci prendere !!:?<br />
Riuscite a darmi una mano ?</p>
<p dir="auto">Grazie !</p>
]]></description><link>https://dev.connect.gt/topic/163402/piccolo-problema</link><generator>RSS for Node</generator><lastBuildDate>Thu, 26 Nov 2026 13:27:19 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/163402.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 27 Dec 2011 09:26:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Piccolo problema... on Fri, 30 Dec 2011 20:01:49 GMT]]></title><description><![CDATA[<p dir="auto">mysql_query($database,"INSERT INTO $db_table (<code>campo1</code>,<code>campo2</code>,...,<code>campon</code>)<br />
VALUES (<code>valorecampo1</code>,<code>valorecampo2</code>,...,<code>valorecampon</code>)  or die(mysql_error());</p>
<p dir="auto">Controlla le parentesi, non sono sicuro che vadano bene</p>
]]></description><link>https://dev.connect.gt/post/1044470</link><guid isPermaLink="true">https://dev.connect.gt/post/1044470</guid><dc:creator><![CDATA[joshua.whopper]]></dc:creator><pubDate>Fri, 30 Dec 2011 20:01:49 GMT</pubDate></item><item><title><![CDATA[Reply to Piccolo problema... on Tue, 27 Dec 2011 13:42:12 GMT]]></title><description><![CDATA[<p dir="auto">E' sbagliato la sintassi del INSERT MySQL, dai un'occhiata <a href="http://dev.mysql.com/doc/refman/5.5/en/insert.html" rel="nofollow ugc">dev.mysql.com/doc/refman/5.5/en/insert.html</a>.</p>
]]></description><link>https://dev.connect.gt/post/1044461</link><guid isPermaLink="true">https://dev.connect.gt/post/1044461</guid><dc:creator><![CDATA[linoma]]></dc:creator><pubDate>Tue, 27 Dec 2011 13:42:12 GMT</pubDate></item></channel></rss>