News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

[HELP] Saving text to MySQL - may be useful to many others

Started by Az, June 03, 2005, 06:57:52 AM

Previous topic - Next topic

Az

Let's start with this code:

  $_REQUEST['memberSig'] = isset($_REQUEST['memberSig']) ? (int)$_REQUEST['memberSig'] : 0;

Here it saves the data to the 'memberSig' field as an integer, and if anything other than a number is inputted, it saves the data as a '0'.

I want to get it so that it can save letters to the same field in the database instead. What do I put instead of 'int'?

Please help.
Many thanks.

Saleh

remove (int)
$_REQUEST['memberSig'] = isset($_REQUEST['memberSig']) ? $_REQUEST['memberSig'] : 0;

We don't need a reason to help people

Az


Thanks for your reply,
I've tried that but then I get the following error when using text:

QuoteUnknown column 'abc' in 'field list'

I assume that the 'memberSig' field in the database has to be a text type??

Az

db_query("
      UPDATE {$db_prefix}inactive SET
         memberSig = $_REQUEST[memberSig],
         anothernumber = $_REQUEST[anothernumber]
      WHERE   ID_RULE=$_REQUEST[id]
      LIMIT 1
      ", __FILE__, __LINE__);

It refers to line 123, which is the line which states:

   memberSig = $_REQUEST[memberSig],


I've also changed the column type of the memberSig field thing to varchar(30), it will still accept integers being loaded into and read from the database but still does not do text (even after implementing Saleh's suggestion). Oh and if I put in the value 'abc' directly into the database via phpAdmin it will read the data correctly - it just won't save it when I try to input it using php!!

[Unknown]

 db_query("
      UPDATE {$db_prefix}inactive
      SET
         memberSig = '$_REQUEST[memberSig]',
         anothernumber = $_REQUEST[anothernumber]
      WHERE ID_RULE = $_REQUEST[id]
      LIMIT 1", __FILE__, __LINE__);

-[Unknown]

Az


Advertisement: