| Author |
php and mysql problems |
engelavdod
Member

Posts: 50
Location: wales
Joined: 01.05.05 Rank: Apprentice |
|
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
 |
|
| Author |
RE: php and mysql problems |
mido
Member
Posts: 613
Location: Cairo, Egypt
Joined: 27.01.07 Rank: God |
|
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).
|
|
| Author |
RE: php and mysql problems |
engelavdod
Member

Posts: 50
Location: wales
Joined: 01.05.05 Rank: Apprentice |
|
cheers for the reply dude
heres the code for the submit page
<?php
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??
 |
|
| Author |
RE: php and mysql problems |
spyware
Member

Posts: 4190
Location: The Netherlands
Joined: 14.04.07 Rank: God Warn Level: 90
|
|
Post the source of include.php

"The chowner of property." - Zeph Widespread intellectual and moral docility may be convenient for leaders in the short term,
but it is suicidal for nations in the long term. - Carl Sagan Since the grid is inescapable, what were the earlier lasers about? Does the corridor have a sense of humor? - Ebert |
|
| Author |
RE: php and mysql problems |
mido
Member
Posts: 613
Location: Cairo, Egypt
Joined: 27.01.07 Rank: God |
|
|
spyware wrote:
Post the source of include.php
I don't think that you need that, since it's :
elseif(strlen($name)<1);
Remove the semi-colon.
Btw, here also :
$insertmessage=("INSERT into chatmessages (name,IP,postime,message) values('$name','$ip','$thedate','$message')";
Change to ");.
Edited by mido on 22-02-08 13:19 |
|
| Author |
RE: php and mysql problems |
spyware
Member

Posts: 4190
Location: The Netherlands
Joined: 14.04.07 Rank: God Warn Level: 90
|
|
Post the source of include.php.

"The chowner of property." - Zeph Widespread intellectual and moral docility may be convenient for leaders in the short term,
but it is suicidal for nations in the long term. - Carl Sagan Since the grid is inescapable, what were the earlier lasers about? Does the corridor have a sense of humor? - Ebert
Edited by spyware on 22-02-08 13:25 |
|
| Author |
RE: php and mysql problems |
mido
Member
Posts: 613
Location: Cairo, Egypt
Joined: 27.01.07 Rank: God |
|
|
spyware wrote:
Post the source of include.php.
? connect.php?
|
|
| Author |
RE: php and mysql problems |
spyware
Member

Posts: 4190
Location: The Netherlands
Joined: 14.04.07 Rank: God Warn Level: 90
|
|
|
mido wrote:
? connect.php?
Actually, neither. I need the (sql)source of the chatlog thing, just read this thing using BOTH eyes.

"The chowner of property." - Zeph Widespread intellectual and moral docility may be convenient for leaders in the short term,
but it is suicidal for nations in the long term. - Carl Sagan Since the grid is inescapable, what were the earlier lasers about? Does the corridor have a sense of humor? - Ebert |
|