Help - Search - Members - Calendar
Full Version: small code
The Planet Forums > General > The Lounge
patriotcow
Aprreciate your help if you can spot the error in this, the error is Parse error: parse error, unexpected T_STRING in /home/patriot/public_html/publish.php on line 14

CODE
<?php

require_once("./connect.php");

?>

<form action="<?php echo $_server['PHP_SELF']; ?> method="post">

<label>Insert news here:<br />

<textarea mame="newstext" rows="10" cols="40">

</textarea></label><br />

<input type="submit" value="SUBMIT" />

</form>

<?php

if (isset($_POST['newstext'])) {

$newstext = $_POST['newstest'];

$sql = "INSERT INTO news SET"

newstext = '$newstext';

if (@mysql_query($sql)) {

echo '<p>News has been submitted</p>';

} else {

echo '<p>Error adding news: ' .

mysql_error() . '</p>';

}

}

?>


Thanks alot! icon_smile.gif
eddy2099
I have no knowledge of PHP but shouldn't each command line terminate with a ';' ?

Line 13 reads

CODE
$sql = "INSERT INTO news SET"


should it be

CODE
$sql = "INSERT INTO news SET";


Just a thought.
patriotcow
Thanks for that I think that fixed somthing, new error now sadfully icon_sad.gif
Parse error: parse error, unexpected '=' in /home/patriot/public_html/publish.php on line 14
CODE
<?php

require_once("./connect.php");

?>

<form action="<?php echo $_server['PHP_SELF']; ?> method="post">

<label>Insert news here:<br />

<textarea mame="newstext" rows="10" cols="40">

</textarea></label><br />

<input type="submit" value="SUBMIT" />

</form>

<?php

if (isset($_POST['newstext'])) {

$newstext = $_POST['newstest'];

$sql = "INSERT INTO news SET";

newstext = '$newstext';

if (@mysql_query($sql)) {

echo '<p>News has been submitted</p>';

} else {

echo '<p>Error adding news: ' .

mysql_error() . '</p>';

}

}

?>


I am no expert this is my first site I am coding in php with an admin side to it. icon_smile.gif
patriotcow
Ok I managed to get the form to display at http://www.patriotcow.com/publish.php
but when you submit I dont know why it does what it does.
Thanks for the help.
eddy2099
Spotted another issue

CODE
<form action="<?php echo $_server['PHP_SELF']; ?> method="post">


gives you

CODE
<form action=" method="post>


Shouldn't it be

CODE
<form action="<?php echo $_server['PHP_SELF']; ?>"  method="post">
talkster5
Have you tried using www.phpbuilder.com ? You will get a lot more help there.
DeadEye686
CODE
$sql = "INSERT INTO news SET";

newstext = '$newstext';


should be

CODE
$sql = "INSERT INTO news (newstext) VALUES ('$newstext')";


and for SQL injection protection, I would use:

CODE
$sql = sprintf("INSERT INTO news (newstext) VALUES ('%s')", mysql_real_escape_string($newstext));


(note the above is all one line if it breaks down into two on your display)
patriotcow
Ok thanks for that both of you, it works good now icon_smile.gif http://vbulletinstudio.com simple but can add features now I have the basics done icon_smile.gif
patriotcow
Not happy now somone took advantage icon_sad.gif
Humper92
why does vbulletinstudio.com go to putfile.com?
patriotcow
Not sure somone inserted loads of weird codes :shock: And disgusting pics. should be ok now.
gordonrp
QUOTE (Humper92)
why does vbulletinstudio.com go to putfile.com?


he he icon_lol.gif

gp
DeadEye686
QUOTE (gordonrp)
QUOTE (Humper92)
why does vbulletinstudio.com go to putfile.com?


he he icon_lol.gif

gp


evil! icon_razz.gif
richyc
Bit o'warning: going to vbulletinstudio.com at the moment spawns a lot of pop/new windows(!) I had to forcably kill Firefox for the first time ever icon_sad.gif

I did try my hand and "cleaning up" the database, but either patrioitcow has now secured it against further exploits or I'm not as good at MySQL injection as I thought I was....
Paul
Small question; do you have permission from vbulletin to use their name, or is this going to be the whole paypal thing over again?
JustGags
QUOTE (richyc)
Bit o'warning: going to vbulletinstudio.com at the moment spawns a lot of pop/new windows(!) I had to forcably kill Firefox for the first time ever icon_sad.gif


Yeah, same here. I was pissed.
patriotcow
They dont mind but I mind who ever put that code in again, had to force all my firefox to close and I was in a middle of somthing. :shock:
atech
Well I see that you have stopped HTML being entered now - so it should be ok for a bit.

You may want to log their IP address also using the $HTTP_SERVER_VARS["REMOTE_ADDR"]; variable....
adamuk
QUOTE (DeadEye686)
CODE
$sql = "INSERT INTO news SET";

newstext = '$newstext';


also newstext needs to be $newstext
DeadEye686
No, the code was wrong to begin with - the SQL statement had been split onto two lines accidentally
SilveR
I see you've got all your dangerous characters escaped. Good job. icon_smile.gif
patriotcow
thanks gordan for telling me what function I needed. now just need to change the query so it does the newest at the top and shows only 3 icon_smile.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.