Page 1 of 1

preparing message to keep in bd? mmm

Posted: Sat Nov 18, 2006 3:50 pm
by visonardo
Im reading db content and keep it again, but exactly like i took it from db´s field. When i try keep it show me error near quotes that i use to delimit the text field, in this case single quotes. how did they to keep it in the db? and the problem: how i must do to keep it without change all?


perhaps you would ask yoursef why i want keep something that didnt change, the answer is that im in a server that dont allow me access to my db from others servers, then i did to php, that pass between the data and in the new server i keep it in the db new. I cant do backup almost because the db is more than 200mb (exactly ~230mb) and when i use system(); sentence to do that it stop in the middle´s task :?

Posted: Sat Nov 18, 2006 3:58 pm
by califdon
Hola! Your English is better than my Spanish, but it is still quite difficult for many of us to read. I say that in a friendly way, because we would like to help you with your problem if we can. It would probably help if you include the PHP code that you are using, then we can all speak the same language: PHP! :?

Posted: Sat Nov 18, 2006 4:05 pm
by visonardo


PHP file in new server (this request to the old server the data and keep it in the new server)

Code: Select all

include('conection.php');
$link=conectarse();


$tabla=$_GET['tabla'];
$cmp=$_GET['cmp'];
if(!isset($_GET['cmp']) || !isset($_GET['tabla'])){
	echo 'faltan parametros por url';
	exit;
}

set_time_limit(300);
$a=file('http://[somesite].com/control/bd.php?tabla='.$tabla.'&cmp='.$cmp);
if(is_numeric(strpos('@',$a[0]))){
	echo $a[0];
	echo '<br>#18';
	exit;
}
echo '<b>TOTAL: <font color=#ff0000>'.$a[0].'</font></b><p>';
$a=explode(' ',trim($a[1]));

echo '<div align=center>';
for($i=0;$i<10;$i++)
{
	global $link,$tabla,$cmp;
	set_time_limit(300);
	$show='';
	$b=file('http://[somesite].com/control/bd.php?id='.$a[$i].'&tabla='.$tabla.'&cmp='.$cmp);
	$show=trim(implode("\n",$b));
	mysql_query($show,$link) or die(mysql_error().'<p>'.$show);
	echo '<img src="http://pirata777.com/phpBB2/images/bot/ok.jpg" border=0>';
}
echo '<h1>JOYA!</h1>';



PHP from the old server

Code: Select all

<?

include('conection.php');
$link=conectarse();

if(!isset($_GET['cmp']) || !isset($_GET['tabla'])){
	echo '@ERROR #1';
	exit;
}

$tabla=$_GET['tabla'];
$g=$_GET['cmp'];

if(!isset($_GET['id']))
{
	global $tabla,$g;
	$hola='SELECT '.$g.' FROM phpbb_'.$tabla;
	$sql=mysql_query($hola,$link) or die('@mysql =>'.mysql_error());
	echo mysql_num_rows($sql);
	echo "\n";
	while($res=mysql_fetch_assoc($sql))
		echo $res['post_id'].' ';
	exit;
}

$sql2='SELECT * FROM phpbb_'.$tabla.' WHERE '.$g.'='.$_GET['id'];
$sql=mysql_query($sql2,$link);
if(!$sql){
	echo '@ERROR <b>'.$sql2.'</b>';
	exit;
}	
$veo=mysql_fetch_assoc($sql);
$mem=count($veo)-1;
echo 'INSERT INTO phpbb_'.$tabla.' (';
$guia=0;
foreach($veo as $k => $veo_)
{
	echo $k;
	if($guia!=$mem)
		echo ', ';
	else
		echo ') VALUES (';
	$guia++;
}
$guia=0;
foreach($veo as $k => $veo_)
{
	global $mem, $guia;
	echo ' ';
	$com=(is_numeric($veo[$k]))?'':'\'';
	echo $com.$veo[$k].$com;
	$proximo=($guia==$mem)?')':', ';
	echo $proximo;
	$guia++;
}

Posted: Sat Nov 18, 2006 4:31 pm
by visonardo
obiously that the problem is not in the script really, the task is keep it in the db exactly like is in old db. i tried puting single quotes to alphanumeric values show me error, tried with ` and nothing too, show me error, that (for example)

$query='insert into table (field_number,field_alph) VALUES (9, `abcdef`)';

when i do this query, using `, mysql_error(); say "unknow field 'abcdef' in field list" :?, then if i try with ' (single quote) had problem with their value because i would need scape them before keep in db and i cant change content, i dont sould change that.

Posted: Sat Nov 18, 2006 5:44 pm
by visonardo
understand? if i take a data from a table, and (no change did) do an update with this date it should work, ok. dont work. Why, i dunno.

Posted: Sat Nov 18, 2006 8:13 pm
by evilchris2003
Why do you need to update data that hasnt changed?

Posted: Sat Nov 18, 2006 8:35 pm
by califdon
visonardo wrote:obiously that the problem is not in the script really, the task is keep it in the db exactly like is in old db. i tried puting single quotes to alphanumeric values show me error, tried with ` and nothing too, show me error, that (for example)

$query='insert into table (field_number,field_alph) VALUES (9, `abcdef`)';

when i do this query, using `, mysql_error(); say "unknow field 'abcdef' in field list" :?, then if i try with ' (single quote) had problem with their value because i would need scape them before keep in db and i cant change content, i dont sould change that.
You are using single-quote (') around entire SQL query, and back-tick (`) around value. Try using double-quote around entire SQL query and single-quote (') around value, like:

Code: Select all

$query="insert into table (field_number,field_alph) values (9,'abcdef')";