View Full Version : Code help please
Hey,
I need help with this code please
else
{
$id = $mybb->user["uid"];
$news = strip_tags($_POST["news"]);
$games = strip_tags($_POST["games"]);
$vids = strip_tags($_POST["vids"]);
$imgs = strip_tags($_POST["imgs"]);
$favs = strip_tags($_POST["favs"]);
$forum = strip_tags($_POST["forum"]);
$stats = strip_tags($_POST["stats"]);
$notes = strip_tags($_POST["notes"]);
$dbh = mysql_connect ("localhost", "user", "pass") or die
("I cannot connect to the database because: " . mysql_error());
mysql_select_db ("database");
[THIS LINE] mysql_query("INSERT INTO `database`.`table` (`users_homepage_id`, `users_homepage_news`, `users_homepage_games`, `users_homepage_vids`, `users_homepage_imgs`, `users_homepage_favs`, `users_homepage_forum`, `users_homepage_notes`, `users_homepage_stats`) VALUES('$id','$news','$games','$vids','$imgs','$fa vs','$forum','$stats','notes')") or die(mysql_error()); [END OF LINE]
echo "<span style=\"background-color: yellow\">\"Sbumitted</span>";
}The line with [THIS LINE] is giving the error below (Obviously [THIS LINE] and [END OF LINE] arn't on the actual page :p
Parse error: syntax error, unexpected T_VARIABLEAnyone got any ideas why :S I can't work it out
Thanks in advance
Joe :D
which line does the error respond to?
This one is giving the error
mysql_query("INSERT INTO `database`.`table` (`users_homepage_id`, `users_homepage_news`, `users_homepage_games`, `users_homepage_vids`, `users_homepage_imgs`, `users_homepage_favs`, `users_homepage_forum`, `users_homepage_notes`, `users_homepage_stats`) VALUES('$id','$news','$games','$vids','$imgs','$fa vs','$forum','$stats','notes')") or die(mysql_error());</span></span>
LMS16
18-12-2009, 07:31 PM
Looking at the code, correct me if Im wrong but shouldnt it be this...
mysql_query("INSERT INTO `database`,`table` (`users_homepage_id`, `users_homepage_news`, `users_homepage_games`, `users_homepage_vids`, `users_homepage_imgs`, `users_homepage_favs`, `users_homepage_forum`, `users_homepage_notes`, `users_homepage_stats`) VALUES('$id','$news','$games','$vids','$imgs','$fa vs','$forum','$stats','notes')") or die(mysql_error());
Lew.
Looking at the code, correct me if Im wrong but shouldnt it be this...
Lew.
What have you changed :s I put it in though it's still not working :(
Joe
Protege
18-12-2009, 08:22 PM
Shoved that in my IDE, and it had no errors. The code you supplied I cant see anything that would make that error appear, post all of the code (at least the whole if statement).
LMS16
18-12-2009, 08:50 PM
Well I cant see anything wrong with that code or anything that would cause that error...
All I can suggest is, rewriting the code...
Lew.
Here's the whole code on that page
<?php require_once('config.php'); ?>
<?php
if($mybb->user['uid'])
{
// logged in
echo "Hello! As part of the new Nexdana you can change what you see when you're logged into Nexdana. Simply tick the checkbox if you do want it on your homepage, untick it if you don't!";
echo '<SCRIPT>
function enableField(form,input)
{
var formname = form;
var formfield = input;
document.contactform.o_subject.disabled=false;
document.contactform.subject.disabled=true;
document.getElementById("o_subject").style.display = "inherit";
document.getElementById("subject").style.display = "none";
}
</SCRIPT>
<form action="" enctype="multipart/form-data" method="post" name="homepage">
<label>Site News: <input name="news" type="checkbox" value="1"></label><br />
<label>Latest Games: <input name="games" type="checkbox" value="1"></label><br />
<label>Latest Videos: <input name="vids" type="checkbox" value="1"></label><br />
<label>Latest Images: <input name="imgs" type="checkbox" value="1"></label><br />
<label>Your favourites: <input name="favs" type="checkbox" value="1"></label><br />
<label>Latest forum posts: <input name="forum" type="checkbox" value="1"></label><br />
<label>Stats box: <input name="stats" type="checkbox" value="1"></label><br />
<label>Your notes: <input name="notes" type="checkbox" value="1"></label><br />
<br />
<input type="submit" value="save" name="submit"/></form>
<br />
</font></div><div class="right-bot"></div>
</div>';
}
else
{
//logged out
echo "You must be logged in to change your homepage settings. Please login then come back";
}
?>
<?php
$id = $mybb->user["uid"];
$news = strip_tags($_POST["news"]);
$games = strip_tags($_POST["games"]);
$vids = strip_tags($_POST["vids"]);
$imgs = strip_tags($_POST["imgs"]);
$favs = strip_tags($_POST["favs"]);
$forum = strip_tags($_POST["forum"]);
$stats = strip_tags($_POST["stats"]);
$notes = strip_tags($_POST["notes"]);
$dbh = mysql_connect ("localhost", "user", "pass") or die
("I cannot connect to the database because: " . mysql_error());
mysql_select_db ("db");
mysql_query("INSERT INTO 'db','tbl' (`users_homepage_id`, `users_homepage_news`, `users_homepage_games`, `users_homepage_vids`, `users_homepage_imgs`, `users_homepage_favs`, `users_homepage_forum`, `users_homepage_notes`, `users_homepage_stats`) VALUES('$id','$news','$games','$vids','$imgs','$fa vs','$forum','$stats','notes')") or die(mysql_error());
echo "<span style=\"background-color: yellow\">\"Your settings are now saved</span>";
unset($_POST);
?>
The error is still
Parse error: syntax error, unexpected T_VARIABLE in settings.php on line 71
and the line is
mysql_query("INSERT INTO 'db','tbl' (`users_homepage_id`, `users_homepage_news`, `users_homepage_games`, `users_homepage_vids`, `users_homepage_imgs`, `users_homepage_favs`, `users_homepage_forum`, `users_homepage_notes`, `users_homepage_stats`) VALUES('$id','$news','$games','$vids','$imgs','$fa vs','$forum','$stats','notes')") or die(mysql_error());
Joe :)
Protege
18-12-2009, 09:37 PM
Again, nothing "wrong" with the syntax there either. Are you sure the page you are looking on is 'settings.php' ? If it isnt, the line of error is on the settings page.
Yep, definitely pasting the settings page there and getting the error on that page
Chippiewill
19-12-2009, 01:16 PM
Yep, definitely pasting the settings page there and getting the error on that page
Have you tried putting some valid code before the troublesome line to see if it's to do with that line or because you haven't closed something before there?
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.