[help] php

Status
Not open for further replies.

JayNZ

Member
Feb 22, 2011
78
7
Hey could someone please fix this code for me,

I get a 500 - Internal server error.
When i use the code i made below

PHP:
$u = mysql_real_escape_string( strip_tags( $_GET["user"],NULL,NULL,NULL,15);
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,638
2,393
Well what about:

PHP:
<?php
$u = mysql_real_escape_string( strip_tags( $_GET['user'] ) );
if( strlen( $u ) > 15 )
{
	echo "cant be more than 15";
}
else
{
	//rest of code here.
}
?>
 

JayNZ

Member
Feb 22, 2011
78
7
Wow thanks for the quick replys :]
And thanks to Kryptos.
--- edit ---
Theres no error, but its not showing anything..
index.php?user=JayNZ
shows the default text, but thats it.
 

Kryptos

prjRev.com
Jul 21, 2010
2,205
1,252
PHP:
$u = mysql_real_escape_string(strip_tags($_GET['user']));

if(strlen($u) > 15 || !isset($u))
{
 echo 'invalid name';
}
else
{
echo $u;
}

Try that.
 

JayNZ

Member
Feb 22, 2011
78
7
M0nstas code sorta works..
How can i make it so if its abcdefghijklmn123456789
and it was limited to 4 it would only show
abcd ?
 

Kryptos

prjRev.com
Jul 21, 2010
2,205
1,252
M0nstas code sorta works..
How can i make it so if its abcdefghijklmn123456789
and it was limited to 4 it would only show
abcd ?

PHP:
$u = mysql_real_escape_string(strip_tags($_GET['user']));

if(!isset($u))
{
 echo 'cannot find user';
}
else
{
echo substr($u, 0, 15); //Will limit to 15
}

Use that.
 

RastaLulz

fight teh power
Staff member
May 3, 2010
3,934
3,933
M0nstas code sorta works..
How can i make it so if its abcdefghijklmn123456789
and it was limited to 4 it would only show
abcd ?

PHP:
<?php
if(isset($_GET['user'])) {
  if(strlen($_GET['user']) > 15 || strlen($_GET['user']) < 1) {
	  echo 'Sorry, but your username must be one to 15 characters long.';
  }else if($_GET['user'] != preg_replace('/[^a-zA-Z0-9]/', '', $_GET['user'])) {
  	echo 'Sorry, but your username can only contain letters and numbers.';
  }else{
   	//run success code
  }
}
 
Status
Not open for further replies.

Users who are viewing this thread

Top