Jump to content

Truncated Incorrect Error


shujjah

Recommended Posts

ok so on the error page I only get the error ( you can try it yourself just posted a link in my previous post )but If I replace the 1 in the link with 0 I get thisgtitle = category = glob_game = glob_console = Game id = 0-Gears-Of-WarGet Id0-Gears-Of-War which means the get id variable contains this 0-Gears-Of-Warthanks,

Link to comment
Share on other sites

Yeah, either the htaccess rule is not correct (there are 2 rules for game.faq), and is sending more information than it should, or the PHP code needs to be changed to expect something in that form and convert it. MySQL sees the hyphens as subtraction operators and thinks you're trying to do a math operation, which is what the error is about.

Link to comment
Share on other sites

Like I said, either change the htaccess rule or add PHP code to expect a value like that and convert it. You can use explode to split the ID around the dashes, and use intval to convert the first item (the ID) to a number.

Link to comment
Share on other sites

either change the htaccess rule or add PHP code to expect a value like that and convert it

and how to do that ? I mean which part should I change ?Isn't there a php function that I can use which removes all the alphabets and those sign values for a given variable so that only numeric values are left ?

Link to comment
Share on other sites

and how to do that ? I mean which part should I change ?
First look at the code and figure out what it's doing and why it's doing that. When you understand the code you'll know how to change it to do something else.
Isn't there a php function that I can use which removes all the alphabets and those sign values for a given variable so that only numeric values are left ?
The intval and floatval functions will convert a string to a number. If the string starts with at least one digit, like it does in your case, then it will use all characters until it gets to a non-digit for the numeric value.
Link to comment
Share on other sites

Ah finally finally finally *shew* finally got it all sorted out apparently there were these two

RewriteRule ^game.cheats-([0-9]*)-(.*).html index.php?page=Games&action=showgame&id=$1&show=Cheats [L,NS]RewriteRule ^game.media-([0-9]*)-([0-9*]*)-(.*).html index.php?page=Games&action=showgame&id=$1&show=Media&nav=$3 [L,NS]RewriteRule ^game.articles-([0-9]*)-(.*).html index.php?page=Games&action=showgame&id=$1&show=Articles [L,NS]RewriteRule ^game.faq-([0-9]*)-(.*).html index.php?page=Games&action=showgame&id=$1&show=FAQ [L,NS]RewriteRule ^game.achievements-([0-9]*)-(.*).html index.php?page=Games&action=showgame&id=$1&show=Achievements [L,NS]RewriteRule ^game.files-([0-9]*)-(.*).html index.php?page=Games&action=showgame&id=$1&show=Files [L,NS]RewriteRule ^game.video-([0-9]*)-(.*).html index.php?page=Games&action=showgame&id=$1&show=Video [L,NS]RewriteRule ^game.articles-(.*)-(.*).html index.php?page=Games&action=showgame&id=$1&show=articles [L,NS]RewriteRule ^game.faq-(.*)-(.*).html index.php?page=Games&action=showgame&id=$1&show=faq [L,NS]RewriteRule ^game.achievements-(.*)-(.*).html index.php?page=Games&action=showgame&id=$1&show=achievements [L,NS]RewriteRule ^game.files-(.*)-(.*).html index.php?page=Games&action=showgame&id=$1&show=files [L,NS]RewriteRule ^game.media-(.*)-(.*).html index.php?page=Games&action=showgame&id=$1&show=media [L,NS]RewriteRule ^game.video-(.*)-(.*).html index.php?page=Games&action=showgame&id=$1&show=video [L,NS]RewriteRule ^game.cheats-(.*)-(.*).html index.php?page=Games&action=showgame&id=$1&show=cheats [L,NS]

and I just had to change their relative positions to get the error fixed :/ strange yeah but it worked :)but these problems never end do they ?.. although I am not getting an error but I am getting a blank part of the page where it should show all the values from the dbjust look at any of the scripts ( for example the one I posted below ) .... all the variables are echoed and they are all correct just checked with my db but strangely the values arent showing up...just to confirm heres what my db contains

Full Texts id cat_id title url game date views submitter platform description timestamp allow_rating allow_comments Edit Delete 1 1 Screen test 1 L:D images/uploads/20090329_rankkk.JPG Gears Of War 2 Mar 29, 2009 10:41 1 SpEeDyZ x360 ahahahahhhaa 1238337704
heres the script
//===================================================// 	SUB PAGE > GAME MEDIA//-----------------------------------------------------------------echo "gtitle = $gtitle";echo "category = $category";echo "glob_game = $glob_game";echo "glob_console = $glob_console";echo "Game id = $_REQUEST[id] ";echo "<br />";echo "Get Id";echo $_GET['id'];		$divtitle = "$lang_media";		include "templates/$skin/divtitle.php";		$res = mysql_query("SELECT * from ccms_screenshots WHERE game=\"$glob_game\" and platform=\"$glob_console\" order by id desc") or die('Line ' . __LINE__ . ': Error: ' . mysql_error()); 		$resc = mysql_num_rows($res);		$mcounter = mysql_query("SELECT * from ccms_screenshots WHERE game=\"$glob_game\" and platform=\"$glob_console\"") or die('Line ' . __LINE__ . ': Error: ' . mysql_error()); 		$mediacount = mysql_num_rows($mcounter);		if (!$mediacount) {		} else {			$i=0;			if (mysql_num_rows($res) > 0) {echo "	<table border=\"0\" cellspacing=\"5\" cellpadding=\"1\" align=\"center\">	<tr>\n";				while ($row = mysql_fetch_assoc($res)) {					if (!($i%4))					echo ($i!=0 ? "</tr>" : "")."<tr>";	 echo "		<td valign=\"top\"><center><a href=\"media-". $row['id'] .".html\"><img width=\"100\" height=\"75\" border=\"0\" src=\"thumbnailer.php?image=" .$row['url'] ."&type=Media\" border=\"0\"></a></td>\n";				$i++;  				}    			for ($cnt=$i;$cnt%4>0;$cnt++) echo "		<td> </td>\n"; echo "	</tr>	</table>\n";  			}		}	}	echo "$res";echo "$resc";	echo "$mcounter";echo "$mediacount";echo "just a test to see wether the echo works here or not!";

and when I echo the 4 queries I get nothing .. which means that the query is empty ? But how can that be the values are correctyou can see it yourselfthe game http://gamerzgalore.net/CCMS/game-1-Gears-Of-War-2.htmlfrom the gamebar open media or the direct linkhttp://gamerzgalore.net/CCMS/game.media-1-...s-Of-War-2.htmlThanks again for all your help!

Link to comment
Share on other sites

I'm not sure I see the problem on the page. You might want to have PHP print out the SQL query and run it in phpMyAdmin. Also, I'm not sure why you're doing it but these two queries are doing the exact same thing:

		$res = mysql_query("SELECT * from ccms_screenshots WHERE game=\"$glob_game\" and platform=\"$glob_console\" order by id desc") or die('Line ' . __LINE__ . ': Error: ' . mysql_error()); 		$resc = mysql_num_rows($res);		$mcounter = mysql_query("SELECT * from ccms_screenshots WHERE game=\"$glob_game\" and platform=\"$glob_console\"") or die('Line ' . __LINE__ . ': Error: ' . mysql_error()); 		$mediacount = mysql_num_rows($mcounter);

Link to comment
Share on other sites

I inserted this

SELECT *FROM ccms_screenshotsWHERE game = 'Gears Of War 2'AND platform = 'x360'ORDER BY id DESC;

into my phpmyadmin and I got the row I needed

Showing rows 0 - 0 (1 total, Query took 0.0003 sec)
It showed the correct row....Also not only this other similar scrpts like this one was for media others like for files and Faq are also showing the same blank pageshere are their queriesfor Faqs
//===================================================// 	SUB PAGE > GAME FAQ//-----------------------------------------------------------------echo "gtitle = $gtitle";echo "category = $category";echo "glob_game = $glob_game";echo "glob_console = $glob_console";echo "Game id = $_REQUEST[id] ";echo "<br />";echo "Get Id";echo $_GET['id'];		$divtitle = "$lang_faq";		include "templates/$skin/divtitle.php";		$gamearticles = mysql_query("SELECT * from ccms_gamefaq where gameid=\"$_REQUEST[id]\" order by id asc") or die('Line ' . __LINE__ . ': Error: ' . mysql_error()); echo "		<img src=\"images/spacer2.gif\">		<table width=\"98%\" align=\"center\" $tablereg>		<tr>			<td width=\"45%\" colspan=\"2\" $tdreg3><SPAN class=\"headertitle\"> $lang_title</SPAN></td>			<td width=\"25%\" $tdreg3><SPAN class=\"headertitle\"><center>$lang_date</SPAN></td>			<td width=\"15%\" $tdreg3><SPAN class=\"headertitle\"><center>$lang_author</SPAN></td>			<td width=\"15%\" $tdreg3><SPAN class=\"headertitle\"><center>$lang_views</SPAN></td>		</tr>\n";			$c = 1;			while ($row = mysql_fetch_assoc($gamearticles)) {				$title_start = preg_replace('/[^a-zA-Z0-9 *]/', '', $row[title]); 				$title_seo = str_replace(' ', '-', $title_start);				if ($odd = $c%2 ) { 					$style = "$tdreg2";				} else { 					$style = "$tdreg";				}				$title = $row[title];				$atimestamp = $row[dateline];				$tfid = $row[id];				$platform = $row[cat_id];				$views = $row[views];			 echo "<tr>\n";echo "			<td width=\"5%\" $style><img src=\"images/consoles/$glob_console.gif\"></td>			<td width=\"40%\" $style><SPAN class=\"content\"> <a class=\"content\" href=\"faq-$tfid-$title_seo.html\">$title</a></SPAN></td>			<td width=\"25%\" $style><center><SPAN class=\"content\">\n";//===================================================// 	DATE & TIME DISPLAY//-----------------------------------------------------------------				// Display date if timestamp doesn't exist				if (!$atimestamp || $atimestamp == "0") {					echo "$date";				// Display time stamp				} else {						echo date("$time_an", $atimestamp);				}//===================================================echo "			</SPAN></td>			<td width=\"15%\" $style><center><a class=\"content\" href=\"profile-$row[author].html\">$row[author]</a></td>			<td width=\"15%\" $style><center><SPAN class=\"content\">"; echo number_format($row[views]); echo "</td>		</tr>\n";			$c++;			}echo "		</table>		<img src=\"images/spacer2.gif\">\n";//===================================================

for FIles

	if ($_REQUEST[show] == 'files') {//===================================================// 	SUB PAGE > GAME FILES//-----------------------------------------------------------------echo "gtitle = $gtitle";echo "category = $category";echo "glob_game = $glob_game";echo "glob_console = $glob_console";echo "Game id = $_REQUEST[id] ";echo "<br />";echo "Get Id";echo $_GET['id'];		$divtitle = "$lang_files";		include "templates/$skin/divtitle.php";		$gamefiles = mysql_query("SELECT * from ccms_file where game=\"$gtitle\" and platform=\"$category\"") or die('Line ' . __LINE__ . ': Error: ' . mysql_error()); echo "	<img src=\"images/spacer2.gif\">	<table align=center width=98% $tablereg>	<tr>		<td width=\"60%\" $tdreg3><SPAN class=\"headertitle\"> $lang_file</td>		<td width=\"25%\" $tdreg3><SPAN class=\"headertitle\"><center>$lang_added</td> 		<td width=\"15%\" $tdreg3><SPAN class=\"headertitle\"><center>$lang_hits</td> 	</tr>\n";		$c = 1;		while($row = mysql_fetch_array($gamefiles)) {		if ($odd = $c%2 ) { 			$style = "$tdreg2";		} else { 			$style = "$tdreg";		}		$title_start = preg_replace('/[^a-zA-Z0-9 *]/', '', $row[title]); 		$title_seo = str_replace(' ', '-', $title_start);		$title = $row[title];		$rdate = $row[date];		$ftimestamp = $row[timestamp];		$fid = $row[id];		$hits = $row[hits];echo "	<tr>		<td width=\"60%\" $style><SPAN class=\"content\">";//===================================================// 	FILE TYPE ICONS//-----------------------------------------------------------------			$ext_1 = strrchr($row[dl_url],'.');			if ($ext_1 == ".gif" || $ext_1 == ".jpeg" || $ext_1 == ".png" || $ext_1 == ".jpg") {echo "			<img src=\"images/icon_img.gif\" align=\"absmiddle\" hspace=\"4\" alt=\"Image - .jpg, .gif, .png\" /> ";			}			if ($ext_1 == ".rar" || $ext_1 == ".zip" || $ext_1 == ".tar" || $ext_1 == ".gzip") {echo "			<img src=\"images/icon_archive.gif\" align=\"absmiddle\" hspace=\"4\" alt=\"Archive - .rar, .zip\" /> ";			}			if ($ext_1 == ".mpg" || $ext_1 == ".mpeg" || $ext_1 == ".mov" || $ext_1 == ".avi") {echo "			<img src=\"images/icon_video.gif\" align=\"absmiddle\" hspace=\"4\" alt=\"Video - .mpeg, .mov, .avi\" /> ";			}			if ($ext_1 == ".txt" || $ext_1 == ".doc" || $ext_1 == ".rtf" || $ext_1 == ".word") {echo "			<img src=\"images/icon_doc.gif\" align=\"absmiddle\" hspace=\"4\" alt=\"Text Document - .txt, .doc, .word, .rtf\" /> ";			}			if ($ext_1 == ".pdf") {echo "			<img src=\"images/icon_pdf.gif\" align=\"absmiddle\" hspace=\"4\" alt=\"PDF File\" /> ";			}//===================================================		echo "<a class=\"content\" href=\"file-$fid-$title_seo.html\">$title</a></td>		<td width=\"25%\" $style><center><SPAN class=\"content\">";//===================================================// 	DATE & TIME DISPLAY//-----------------------------------------------------------------			// Display date if timestamp doesn't exist			if (!$ftimestamp || $ftimestamp == "0") {				echo "$rdate";			// Display time stamp			} else {				echo date("$time_an", $ftimestamp);			}//===================================================echo "		</td>		<td width=\"15%\" $style><center><SPAN class=\"content\">"; echo number_format($hits); echo "</td>	</tr>\n";		$c++;		}echo "	</table>	<img src=\"images/spacer2.gif\">\n";	}

SO I guess its a common error with all the queries ?Thanks,

Link to comment
Share on other sites

I'm sure it's going to work if you type the query in phpMyAdmin yourself, but that's not necessarily the same query that PHP is running. Have PHP print out the exact query it's using, and copy and paste that to run it.

Link to comment
Share on other sites

I'm sure it's going to work if you type the query in phpMyAdmin yourself, but that's not necessarily the same query that PHP is running. Have PHP print out the exact query it's using, and copy and paste that to run it.
and what code do I use to print out the exact query .... echo doesnt seem to work .. Thanks,
Link to comment
Share on other sites

this is the code

//===================================================// SUB PAGE > GAME MEDIA//-----------------------------------------------------------------echo "gtitle = $gtitle";echo "category = $category";echo "glob_game = $glob_game";echo "glob_console = $glob_console";echo "Game id = $_REQUEST[id] ";echo "<br />";echo "Get Id";echo $_GET['id']; $divtitle = "$lang_media"; include "templates/$skin/divtitle.php"; $res = mysql_query("SELECT * from ccms_screenshots WHERE game=\"$glob_game\" and platform=\"$glob_console\" order by id desc") or die('Line ' . __LINE__ . ': Error: ' . mysql_error()); $resc = mysql_num_rows($res);echo "Res = $res";echo "<br />";echo "Resc = $resc"; $mcounter = mysql_query("SELECT * from ccms_screenshots WHERE game=\"$glob_game\" and platform=\"$glob_console\"") or die('Line ' . __LINE__ . ': Error: ' . mysql_error()); $mediacount = mysql_num_rows($mcounter);echo "Mcounter = $mcounter";echo "<br />";echo "mediacount = $mediacount"; if (!$mediacount) { } else { $i=0; if (mysql_num_rows($res) > 0) {echo " <table border=\"0\" cellspacing=\"5\" cellpadding=\"1\" align=\"center\"> <tr>\n"; while ($row = mysql_fetch_assoc($res)) { if (!($i%4)) echo ($i!=0 ? "</tr>" : "")."<tr>"; echo " <td valign=\"top\"><center><a href=\"media-". $row['id'] .".html\"><img width=\"100\" height=\"75\" border=\"0\" src=\"thumbnailer.php?image=" .$row['url'] ."&type=Media\" border=\"0\"></a></td>\n"; $i++; } for ($cnt=$i;$cnt%4>0;$cnt++) echo " <td> </td>\n"; echo " </tr> </table>\n"; } } }echo "<br />";echo "Res2 = $res";echo "<br />";echo "Resc2 = $resc";echo "<br />";echo "Mcounter2 = $mcounter";echo "<br />";echo "mediacount2 = $mediacount";echo "<br />";echo "just a test to see wether the echo works here or not!";
only the blue lines show and the red ones do not .. and the orange ones only show the simple text Res2 and Resc2 etc ... the vriables dont show anything .. they are empty ?you can see it yourself herehttp://gamerzgalore.net/CCMS/game.media-1-...s-Of-War-2.html
Link to comment
Share on other sites

You're trying to print a MySQL resource. You need to print the actual query, the text you're telling MySQL to execute. e.g.:echo "SELECT * from ccms_screenshots WHERE game=\"$glob_game\" and platform=\"$glob_console\" order by id desc";You can copy and paste the printed query into phpMyAdmin to run it, or you might be able to see a problem by just looking at it.

Link to comment
Share on other sites

Alright I did as you said and I got this

SELECT * from ccms_screenshots WHERE game="Gears Of War 2" and platform="x360" order by id desc
I inserted it directly into phpmyadmin and I got the row
Showing rows 0 - 0 (1 total, Query took 0.0003 sec)SQL query:SELECT *FROM ccms_screenshotsWHERE game = "Gears Of War 2"AND platform = "x360"ORDER BY id DESCLIMIT 0 , 30
Full Texts id cat_id title url game date views submitter platform description timestamp allow_rating allow_comments Edit Delete 1 1 Screen test 1 L:D images/uploads/20090329_rankkk.JPG Gears Of War 2 Mar 29, 2009 10:41 1 SpEeDyZ x360 ahahahahhhaa 1238337704 1
so what does this mean ? the query is right but the code that is echoing it , is not right ? Thanks!
Link to comment
Share on other sites

I see the box cover there, is that the screenshot? It's only returning 1 record, so there's only going to be 1 image. I was assuming that was the one, and that it was working.Something isn't making sense here. In the code you posted above, there's no reason why the red lines would not show up. There is no if statement or anything telling those not to print. If those are not showing up in the output, then I don't think that code is even running. Are you sure the code you posted is the actual code online? It doesn't look like it is, if it was then it would be printing the stuff you marked in red.Am I looking at the wrong page online or something? You tell it to print the word "mcounter" twice, without any if statements or anything, but the word "mcounter" does not appear in the source in any page I get to on your site. It doesn't look like that's the code that's running.

Link to comment
Share on other sites

I see the box cover there, is that the screenshot? It's only returning 1 record, so there's only going to be 1 image. I was assuming that was the one, and that it was working.Something isn't making sense here. In the code you posted above, there's no reason why the red lines would not show up. There is no if statement or anything telling those not to print. If those are not showing up in the output, then I don't think that code is even running. Are you sure the code you posted is the actual code online? It doesn't look like it is, if it was then it would be printing the stuff you marked in red.Am I looking at the wrong page online or something? You tell it to print the word "mcounter" twice, without any if statements or anything, but the word "mcounter" does not appear in the source in any page I get to on your site. It doesn't look like that's the code that's running.
ahhhhh thanks a lot dude !I figured it out .. it turns out it wasnt a problem with the script but with the htaccess file!it contains links like ]
RewriteRule ^game.media-([0-9]*)-([0-9*]*)-(.*).html index.php?page=Games&action=showgame&id=$1&show=Media&nav=$3 [L,NS]
the Media is with a capital M but in the script it is with a small m .. so I guess the .htaccess files are case sensitive! ok so I dont know how to say this .. but I AM REALLY REALLY THANKFUL! for you helping me out! If there is anything I can do for you just lemme know ...and one more thing what does a Mysql resource Id mean ?
Link to comment
Share on other sites

and one more thing what does a Mysql resource Id mean ?
The ID number is just used by PHP to keep track of the resource (a resource is something like a database connection, file handle, open socket, etc). When you try to print a resource PHP just prints the ID of it, that's about the only meaningful thing it can print for a resource.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...