Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Jan 2001
    Messaggi
    168

    problema con apici in MySql

    Ho un campo tipo testo dove attraverso un form vado ad inserire dei dati, quando il testo che inserisco contiene ' mi restituisce questo errore

    articoloYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1'

    ora il fatto è che mi da questo uesto errore su questa versione di MySql 4.1.12 ma sulla versione 3.23.32 va perfettamente

    Come devo fare a memorizzare i dati dai per evitare il problema dell'apice?

    Io ora uso le funzione che usa Dreaweaver:

    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    {
    $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

    switch ($theType) {
    case "text":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "long":
    case "int":
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
    break;
    case "double":
    $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
    break;
    case "date":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "defined":
    $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
    break;
    }
    return $theValue;
    }

    e poi passo il valore usando (campo) values (%s),
    GetSQLValueString($_POST['campo_form'], "text"));

    Spero di essermi spiegato

    Grazie mille per l'aiuto

    Max

  2. #2
    Utente di HTML.it L'avatar di nicola75ss
    Registrato dal
    Nov 2004
    Messaggi
    12,923
    Leggi due righe più in giù nell'elenco degli ultimi thread
    http://forum.html.it/forum/showthrea...hreadid=966827

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.