/    Sign up×
Community /Pin to ProfileBookmark

Hi im having problems with this script I keep getting different errors, Im to get the board name from createboard in the session, then it goes to createboard2 where the session opnes again and it transfers the data to insert the values into the sql tbale then the session is closed, any help is greatfully appreciated ?

[code=php]
<?php
} else if ($action == “createboard”) {
session_start();
session_register($name);
$name = $post[‘boardname’];
?>

<table width=92% cellspacing=1 border=0 align=center bgcolor=005177 cellpadding=4>
<tr>
<td class=catbg>
Simple Forums :: Admin :: Create A Board
</td>
</tr>
<tr>
<td class=windowbg>
<form method=post name=createboard action=index.php?action=createboard2>
Board Name:
<br/><input type=text id=boardname>
<p><input type=submit value=Submit name=submit id=submit>
</form>
</td>
</table>

<?php
} else if ($action == “createboard2”) {
session_start();
$user = “shoutbox_admin”;
$host = “localhost”;
$password = “admin”;
$database = “shoutbox_simple”;
$connection = mysql_connect($host,$user,$password)
$db = mysql_select_db($database,$connection)
$sql = ‘INSERT INTO `boards` ( `id` , `name` , `topics` , `posts` , `lastreply` ) ‘;
$sql .= ‘VALUES ( “”, “$name”, “0”, “0”, “N/A” );’;
$sql .= ”;
$result = mysql_query($sql);
session_end();
} else {
?>
[/code]

Luke ?

to post a comment
PHP

11 Comments(s)

Copy linkTweet thisAlerts:
@pyroJan 05.2004 — What part is causing trouble and what errors are you getting?
Copy linkTweet thisAlerts:
@lukezwebauthorJan 05.2004 — [i]Originally posted by pyro [/i]

[B]What part is causing trouble and what errors are you getting? [/B][/QUOTE]


i figured it was that part, i got Parse Errors
Copy linkTweet thisAlerts:
@pyroJan 05.2004 — Which line, specifically? The more info you give, the easier it is on me/us, and I like easy. ?
Copy linkTweet thisAlerts:
@lukezwebauthorJan 05.2004 — [i]Originally posted by pyro [/i]

[B]Which line, specifically? The more info you give, the easier it is on me/us, and I like easy. ? [/B][/QUOTE]


i have no idea but i reduced my whole file to jsut that i eliminated that area ?
Copy linkTweet thisAlerts:
@pyroJan 05.2004 — It should be giving you a line number with the error message, but no matter.

Try putting $name = $post['boardname']; before the session_register on line 4 and then chage your SQL to something more like this:

[code=php]$sql = "INSERT INTO boards (id, name, topics, posts, lastreply) VALUES ('', '$name', '0', '0', 'N/A')";[/code]
Copy linkTweet thisAlerts:
@lukezwebauthorJan 05.2004 — [i]Originally posted by pyro [/i]

[B]It should be giving you a line number with the error message, but no matter.



Try putting $name = $post['boardname']; before the session_register on line 4 and then chage your SQL to something more like this:



[code=php]$sql = "INSERT INTO boards (id, name, topics, posts, lastreply) VALUES ('', '$name', '0', '0', 'N/A')";[/code] [/B][/QUOTE]



am trying it now ?
Copy linkTweet thisAlerts:
@lukezwebauthorJan 05.2004 — [i]Originally posted by lukezweb [/i]

[B]am trying it now ? [/B][/QUOTE]



i get:

Parse error: parse error in /home/shoutbox/public_html/simpleforum/index.php on line 214[/quote]
Copy linkTweet thisAlerts:
@lukezwebauthorJan 05.2004 — [i]Originally posted by lukezweb [/i]

[B]i get: [/B][/QUOTE]


thata line had....


$db = mysql_select_db($database,$connection)


so i added a semi-colon and it worked but now ig et on the create boards page......


Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/shoutbox/public_html/simpleforum/index.php:3) in /home/shoutbox/public_html/simpleforum/index.php on line 180

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/shoutbox/public_html/simpleforum/index.php:3) in /home/shoutbox/public_html/simpleforum/index.php on line 180
[/quote]
Copy linkTweet thisAlerts:
@pyroJan 05.2004 — Which is...?
Copy linkTweet thisAlerts:
@lukezwebauthorJan 05.2004 — [i]Originally posted by pyro [/i]

[B]Which is...? [/B][/QUOTE]


the sessions part I think i may knwo where the problem is.....

i have the basic page layout etc then between the body tags have if action= blah stuff in the action part, i have the session stuff whihc wont be valid as its not in the headers so how can i get around this?
Copy linkTweet thisAlerts:
@lukezwebauthorJan 05.2004 — [code=php]
<table width=92% cellspacing=1 border=0 align=center bgcolor=005177 cellpadding=4>
<tr>
<td class=catbg>
Simple Forums :: Admin :: Create A Board
</td>
</tr>
<tr>
<td class=windowbg>
<form method=post name=createboard action=index.php?action=createboard2>
Board Name:
<br/><input type=text id=boardname>
<?php
if ($_POST['submit']) {
$user = "shoutbox_admin";
$host = "localhost";
$password = "admin";
$database = "shoutbox_simple";
$connection = mysql_connect($host,$user,$password)
or die ("Could not connect");
$db = mysql_select_db($database,$connection)
or die ("Could not select");
$sql = "INSERT INTO boards (name, topics, posts, lastreply) VALUES (' ".$_POST['boardname']." ', '0', '0', 'N/A')";
mysql_query($sql);
}
?>
<p><input type=submit value=Submit name=submit id=submit>
</form>
</td>
</table>
[/code]


i decided to use this but there are no errors LOL accept it doent add it any help?
×

Success!

Help @lukezweb spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 1.24,
social: @webDeveloperHQ,
});

legal: ({
terms: of use,
privacy: policy
analytics: Fullres
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: Anonymous,
tipped: article
amount: 1000 SATS,

tipper: @dert,
tipped: article
amount: 1000 SATS,

tipper: @viney352,
tipped: article
amount: 10 SATS,
)...