problem with Spaces in mySQL from the PHP

I know this is a simple problem, but I have yet to get it working with spaces in the characters name EG. ‘GrimReaper 2012’ comes up as GrimReaper’. the only takes the first set of the name and ignores the rest.

The thing is on the first time it goes through the spaces are fine. On the second on they only show the first part of the character. I know I can simply do and enter each bit manually, but that leads to a lot of entries for said people. Can you please help me.

Here is a link to the working with mySQL (albeit with spaces problem)
http://www.legionofdeath.net/lod/Skiller/update.php

[php]update.php
require(“config.php”);
$title = “Update Characters”;
$submit = $_POST[submit];
echo “

”;
if($submit == “Get Character Information”)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ‘http://’.$server.’.outwar.com/myaccount.php’);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, ‘login_username=’.$rga_user.’&login_password=’.$rga_pass);
curl_setopt ($ch, CURLOPT_COOKIEJAR, ‘temp/’.$rga_user.‘cookie.txt’);
curl_setopt ($ch, CURLOPT_COOKIEFILE, ‘temp/’.$rga_user.‘cookie.txt’);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$store = curl_exec ($ch);
curl_setopt($ch, CURLOPT_URL, ‘http://’.$server.’.outwar.com/accounts.php?ac_serverid=’.$server_id);
curl_setopt ($ch, CURLOPT_COOKIEJAR, ‘temp/’.$rga_user.‘cookie.txt’);
curl_setopt ($ch, CURLOPT_COOKIEFILE, ‘temp/’.$rga_user.‘cookie.txt’);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$store = curl_exec ($ch);
curl_close ($ch);
$charactersinfo = explode(‘Crew’,$store);
$charactersinfo = $charactersinfo[1];
$idinfo = explode(‘world.php?suid=’,$charactersinfo);
$charactersinfo = explode(’’,$charactersinfo);
for ($number = 1; $number < sizeof($charactersinfo); $number = $number + 4)
{
$characternameinfo = explode(’
’,$charactersinfo[$number]);
$characternames = $characternames.$characternameinfo[0]."!";
}
for ($number1 = 1; $number1 < sizeof($idinfo); $number1++)
{
$idsinfo = explode(’&serverid=’,$idinfo[$number1]);
$ids = $ids.$idsinfo[0]."!";
}
$ids = explode(’!’,$ids);
$charnames = explode(’!’,$characternames);
echo “”;
for ($number = 0; $number < sizeof($charnames) - 1; $number++)
{
echo ‘’.$charnames[$number].’
’;
}
echo "Please only click once this will take a while but think
of it this way this time is taken off the skilling

";
}
elseif($submit == “Update Orbs and Pants.”)
{
echo ‘
Please Wait This may take a While
’;
$characters = $_POST[‘character’];
for ($number = 0; $number < sizeof($characters); $number++)
{
$info = explode(’!’,$characters[$number]);
$char_name = $info[0];
$char_id = $info[1];
echo ‘<iframe width=-10 frameborder=0 height=-10 src=updatechar.php?charname=’.$char_name.’&charid=’.$char_id.’>’;
}
}
else
{
echo "rawr.
"; } echo "
"; ?>
</div>
[/php]

And this is the second file

[php]
require(“config.php”);
$char_id=$_GET[‘charid’];
$char_name=$_GET[‘charname’];
echo "“;
$result = mysql_query(“SELECT * FROM Character_info WHERE Char_name = ‘$char_name’ AND Char_id = ‘$char_id’ AND RGA_name = ‘$rga_user’ Limit 1”);
if($row = mysql_fetch_array($result))
{
mysql_query(“DELETE FROM Character_skills WHERE Char_id = ‘$char_id’ AND Rga_name = ‘$rga_user’”);
$on1 = 1;
}
else
{
$count = 0;
$result = mysql_query(“SELECT * FROM Character_info WHERE RGA_name = ‘$rga_user’”);
while($row = mysql_fetch_array($result))
{
$count++;
}
}
if($count >= 50)
{
echo ‘’;
}
else
{
if($on1 == 1)
{
//
}
else
{
mysql_query(“INSERT INTO Character_info(‘Char_name’ ,Char_id, RGA_name) VALUES(’$char_name’,’$char_id’,’$rga_user’) “);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ‘http://’.$server.’.outwar.com/world.php?suid=’.$char_id.’&serverid=’.$server_id);
curl_setopt ($ch, CURLOPT_COOKIEJAR, ‘temp/’.$rga_user.$char_name.‘cookie.txt’);
curl_setopt ($ch, CURLOPT_COOKIEFILE, ‘temp/’.$rga_user.‘cookie.txt’);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$store = curl_exec ($ch);
curl_close ($ch);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ‘http://’.$server.’.outwar.com/equipment.php?id=’.$char_id);
curl_setopt ($ch, CURLOPT_COOKIEJAR, ‘temp/’.$rga_user.$char_name.‘cookie.txt’);
curl_setopt ($ch, CURLOPT_COOKIEFILE, ‘temp/’.$rga_user.$char_name.‘cookie.txt’);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$store = curl_exec ($ch);
$mainpants = explode(’

’,$store);
$mainpants = explode(’
’,$mainpants[1]);
$mainpants = explode(“removeItem(’”,$mainpants[0]);
$mainpants = explode(”’,”,$mainpants[1]);
$mainpants = $mainpants[0];
$azitems[‘mpants’]=$mainpants;
//echo(“Main Pants:”.$mainpants.”
");
$item_type = “pants”;
$item_id = $mainpants;
curl_setopt($ch, CURLOPT_URL, ‘http://’.$server.’.outwar.com/item_rollover.php?id=’.$item_id);
curl_setopt ($ch, CURLOPT_COOKIEJAR, ‘temp/’.$rga_user.$char_name.‘cookie.txt’);
curl_setopt ($ch, CURLOPT_COOKIEFILE, ‘temp/’.$rga_user.$char_name.‘cookie.txt’);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$htmlsource = curl_exec ($ch);
//print $htmlsource ."
";
include(‘checkskills.php’);
mysql_query(“UPDATE Character_info SET pants_id = ‘$mainpants’ WHERE Char_name = ‘$char_name’ AND Char_id = ‘$char_id’ AND RGA_name = ‘$rga_user’”);
$orb = explode(’
’,$store);
$orb = explode(’
’,$orb[1]);
$orb = explode(“removeItem(’”,$orb[0]);
for ($number1 = 1; $number1 < sizeof($orb); $number1++)
{
$orb1 = explode("’,",$orb[$number1]);
$orbs = $orbs.$orb1[0].’!’;
print $orb1 . “—” . $orbs . “

”;
}
$orbs = explode(’!’,$orbs);
for ($number1 = 0; $number1 < sizeof($orbs) - 1; $number1++)
{
curl_setopt($ch, CURLOPT_URL, ‘http://’.$server.’.outwar.com/equipment.php?rem=’.$orbs[$number1].’&uid=’.$char_id);
curl_setopt ($ch, CURLOPT_COOKIEJAR, ‘temp/’.$rga_user.$char_name.‘cookie.txt’);
curl_setopt ($ch, CURLOPT_COOKIEFILE, ‘temp/’.$rga_user.$char_name.‘cookie.txt’);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$store = curl_exec ($ch);
}
curl_setopt($ch, CURLOPT_URL, ‘http://’.$server.’.outwar.com/backpack.php?orb=1&id=’.$char_id);
curl_setopt ($ch, CURLOPT_COOKIEJAR, ‘temp/’.$rga_user.$char_name.‘cookie.txt’);
curl_setopt ($ch, CURLOPT_COOKIEFILE, ‘temp/’.$rga_user.$char_name.‘cookie.txt’);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$store = curl_exec ($ch);
$bporbs1 = explode(‘dropitem[]" value="’,$store);
$bporbs = “”;
for ($number1 = 1; $number1 < sizeof($bporbs1); $number1++)
{
$bporbs2 = explode(’" />’,$bporbs1[$number1]);
$bporbs = $bporbs.$bporbs2[0]."!";
print_r($bporbs2);
print “-----” . $bporbs . “

”;
}
$bporbs = explode(’!’,$bporbs);
for ($number1 = 0; $number1 < sizeof($bporbs) - 1; $number1++)
{
	$item_type = "orb";
	$item_id = $bporbs[$number1];
	curl_setopt($ch, CURLOPT_URL, 'http://'.$server.'.outwar.com/item_rollover.php?id='.$bporbs[$number1]);
	curl_setopt ($ch, CURLOPT_COOKIEJAR, 'temp/'.$rga_user.$char_name.'cookie.txt');
	curl_setopt ($ch, CURLOPT_COOKIEFILE, 'temp/'.$rga_user.$char_name.'cookie.txt');
	curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
	$htmlsource = curl_exec ($ch);
	include('checkskills.php');
}

curl_setopt($ch, CURLOPT_URL, 'http://'.$server.'.outwar.com/backpack.php?id='.$char_id);
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'temp/'.$rga_user.$char_name.'cookie.txt');
curl_setopt ($ch, CURLOPT_COOKIEFILE, 'temp/'.$rga_user.$char_name.'cookie.txt');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$store = curl_exec ($ch);
$bpitems1 = explode('dropitem[]" value="',$store);
$bpitems = "";
for ($number1 = 1; $number1 < sizeof($bpitems1); $number1++)
{ 
	$bpitems2 = explode('" />',$bpitems1[$number1]);
	$bpitems = $bpitems.$bpitems2[0]."!";
}
$bpitems = explode('!',$bpitems);

for ($number1 = 0; $number1 < sizeof($bpitems) - 1; $number1++)
{
	$item_type = "pants";
	$item_id = $bpitems[$number1];
	curl_setopt($ch, CURLOPT_URL, 'http://'.$server.'.outwar.com/item_rollover.php?id='.$bpitems[$number1]);
	curl_setopt ($ch, CURLOPT_COOKIEJAR, 'temp/'.$rga_user.$char_name.'cookie.txt');
	curl_setopt ($ch, CURLOPT_COOKIEFILE, 'temp/'.$rga_user.$char_name.'cookie.txt');
	curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
	$htmlsource = curl_exec ($ch);
	include('checkskills.php');
}
echo '<body onLoad=add1()></body>';
curl_close ($ch);

}

?>[/php]

These files do work, I just left out a few bits of non-related parts at the start of each.

ok I’ll narrow it down since I can’t edit it for some reason

[php]update.php

echo ‘

Please Wait This may take a While
’;
$characters = $_POST[‘character’];
for ($number = 0; $number < sizeof($characters); $number++)
{
$info = explode(’!’,$characters[$number]);
$char_name = $info[0];
$char_id = $info[1];
echo ‘<iframe width=-10 frameborder=0 height=-10 src=updatechar.php?charname=’.$char_name.’&charid=’.$char_id.’>’;
}[/php]

[php]updatechar.php

$char_id=$_GET[‘charid’];
$char_name=$_GET[‘charname’];

[/php]

I know it’s a simple problem, but I can’t find where it is too fix it :confused:

Where you do this:
[php]’…?charname=’.$char_name.’&charid…’[/php]

Try this instead:
[php]’…?charname=’.urlencode($char_name).’&charid…’[/php]

Thanks well it solves one part but doesn’t the whole problem.

It now puts in the full name but it still doesn’t put in a name at all now.

Where abouts isn’t it working?

What code now doesn’t work - what is it doing, what should it be doing?

ok, sorry about that.

The code is seems fine up until it has to be inserted in to the mySQL (which is perfect). The original code would only input the first group of chars before the space(s). However now there isn’t any $character_name inserted on the mySQL. (aware that this isn’t the mySQL forum, but I’m trying to fix the PHP problem).

That code just fixed a minor error, but a good one as it now shows your full (including space) name

Pants and orb ids added to database for VapoR z

instead of the previous one which just ended at the first space in name

Pants and orb ids added to database for VapoR

[table] ID bigint(20) No auto_increment Char_name varchar(40) latin1_swedish_ci No Char_id bigint(20) No 0 RGA_name varchar(100) latin1_swedish_ci No Browse distinct values Change pants_id bigint(20) No 0 This is why I’m happy with the mySQL side.

I’m not entirely sure of where exactly the issue lies I’m afraid. But from what I understood, it may be of help for you to, instead of doing this:
[php]mysql_query(“SQL…”);[/php]

Do this:
[php]$sql = “SQL…”;
die(‘The query being run is: "’.$sql.’"’); //obviously remove this line once problem is solved
mysql_query($sql);[/php]

I just want to check what information is currently being passed to MySQL

which one or do you mean all of the mysql on that page?

I’ve done it with two pieces and now notta happens.

Opps pressed it by accessing.

what I was saying was that there was no issue from the no-spaces names at all.
which is why I don’t think there shouldn’t be any problem in the mySQL tbh.

[php]$result = mysql_query(“SELECT * FROM Character_info WHERE Char_name = ‘$char_name’ AND Char_id = ‘$char_id’ AND RGA_name = ‘$rga_user’ Limit 1”);
if($row = mysql_fetch_array($result))
{
$sql=“DELETE FROM Character_skills WHERE Char_id = ‘$char_id’ AND Rga_name = ‘$rga_user’”;
die(‘The query being run is: "’.$sql.’"’); //obviously remove this line once problem is solved
mysql_query($sql);
$on1 = 1;
}
else
{
$count = 0;
$result = mysql_query(“SELECT * FROM Character_info WHERE RGA_name = ‘$rga_user’”);
while($row = mysql_fetch_array($result))
{
$count++;
}
}
if($count >= 50)
{
echo ‘’;
}
else
{
if($on1 == 1)
{
//
}
else
{
$mysql="INSERT INTO Character_info(‘Char_name’ ,Char_id, RGA_name) VALUES(’$char_name’,’$char_id’,’$rga_user’) “;
die(‘The query being run is: "’.$sql.’”’); //obviously remove this line once problem is solved
mysql_query($sql);
}
[/php]

I meant on whatever one isn’t working (I am assuming the one that inserts, and it isn’t inserting names at all if they have spaces?).

I’m afraid I’m not entirely sure what the issue is. If you can clarify what is broken in what way, and what the code is, it will be much easier for me to help.

Well, afaik it is just as the character is inserted into the mySQL, but the mySQL is no the problem as I think I know. I can’t find out which one as of yet I can’t find out which one.

I could always give you perm in to the access the whole php/mySQL section.

Sponsor our Newsletter | Privacy Policy | Terms of Service