Welcome to HBH! If you had an account on hellboundhacker.org you will need to reset your password using the Lost Password system before you will be able to login.

php and mysql problems


ghost's Avatar
0 0

hey guys

i got 2 problems that are bugging me like hell.

1st problem

on my submit page i have this, Parse error: parse error, unexpected T_ELSE in submit.php on line 25, all that is on line 25 is , else, how can i sort this out??

2nd problem

on my chatlog page i have this, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(*) as messagecount from chatmessages' at line 1, how can i sort this one out??

im still learning PHP and MySQL

cheers in advance

engelavdod


mido's Avatar
Member
0 0

For the first problem : That error means that you've put an "else" statement, unexpectedly. Like : if (!$thing) { //code }

else { //normal codeā€¦. }

else // bad statement { //won't be executed and outcome error. }

Or even, a lonely "else" without an "if" above.

And for the second problem, show me the query, and the PHP code. (actually for the first problem too).


ghost's Avatar
0 0

cheers for the reply dude

heres the code for the submit page


include "connect.php";

if(isset($_POST['submit'])) // if submit button push has been detected

{

	$message=$_POST['message'];
	$name=$_POST['name'];
	if(strlen($message)<1)
	
	{
		print "You did not input a message";
		
	}
	
	else if(strlen($name)<1);
	
	{
		print "You did not enter a name, please try again.";
		
	}
	
	else 
	
	{
		$message=strip_tags($message);
		$IP=$_SERVER["REMOTE_ADDR"]; //grabs posters IP
		$checkforbanned=("SELECT IP from ipbans where IP='$IP'");
		$checkforbanned2=mysql_query($checkforbanned) or die("Could not check for banned IPS");
		if(mysql_num_rows($checkforbanned2)>0) //IP is in the banned list
		
		{
			print "Your IP is banned from posting.";
		}
		
		else
		
		{
		
			$thedate = date("U"); // grab data and time of the post
			$insertmessage=("INSERT into chatmessages (name,IP,postime,message) values('$name','$ip','$thedate','$message')";
			mysq_query($insertmessage) or die("Could not insert message");
			
			
		}
	}
	
	

	
}```

and for the 2nd problem do you want the code for chatlog or the sql query??

spyware's Avatar
Banned
0 0

Post the source of include.php


mido's Avatar
Member
0 0

spyware wrote: Post the source of include.php

I don't think that you need that, since it's :

markupelseif(strlen($name)<1)**;**

Remove the semi-colon.

Btw, here also :

markup$insertmessage=("INSERT into chatmessages (name,IP,postime,message) values('$name','$ip','$thedate','$message'**)";**

Change to ");.


spyware's Avatar
Banned
0 0

Post the source of include.php.


mido's Avatar
Member
0 0

spyware wrote: Post the source of include.php.

? connect.php?


spyware's Avatar
Banned
0 0

mido wrote: ? connect.php?

Actually, neither. I need the (sql)source of the chatlog thing, just read this thing using BOTH eyes.