News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Need Help

Started by calthephenom, November 22, 2009, 03:10:34 PM

Previous topic - Next topic

Arantor

Just literally the mysql_query command.

calthephenom

"No Database Selected"
the database is ctpcalforum fyi
and one more thing, what about the $_POST Request for the username
how do i insert the username if they are logged in, and not show the script if they're not

Arantor

Ah, no wonder.

mysql_select_db('cptcalforum');

Is this table in the same database as your forum, before I get into that?

calthephenom

yup, ill test the current addon

calthephenom

yes,it works
and it is the same database

Arantor


calthephenom

what exactly would i do?

calthephenom


<form name="input" action="score_add.php" method="post">
<?php require("../SSI.php"); 
<
h2><center><input type="echo $context["user"]['name'];" name="username" /></h2>
?>

</h3>
<center>"Song:"
<center><input type="text" name="song" />
<center>"Score"
<center><input type="text" name="score" />
<center>"Instrument:"
<center><input type="text" name="instrument" />
<center>"Percent"
<center><input type="text" name="percent" />
<center><input type="submit" value="Submit" />
</form>


i got this, now i just need the username to be uploaded?

Arantor

Try:

<?php require("../SSI.php"); ?>
<h2><center><input type="<?php echo $context["user"]['name'];?> " name="username" /></h2>


Note that will only work if the user is logged in, for which you should check $context['user']['is_logged'] beforehand.

calthephenom

#29
yup, thanks, it works,now just for the score retreival script
heres what i have

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<link rel="stylesheet" type="text/css" href="layout.css" />                                                                 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>View Scores</title>
</head>
<body>
<table width="100%" border="1">
  <tr>
    <th scope="col" width="15%">Player</th>
    <th scope="col" width="15%">Song</th>
    <th scope="col" width="15%">Score</th>
    <th scope="col" width="15%">Instrument</th>
    <th scope="col" width="15%">Percent</th>
  </tr>
<?php
$mysql_server 
"REMOVED";
$mysql_user "REMOVED";
$mysql_password "REMOVED";
$mysql_database "REMOVED";



$connection mysql_connect("$mysql_server","$mysql_user","$mysql_password") or die(mysql_error());

$db mysql_select_db("$mysql_database") or die(mysql_error());  

$result mysql_query("SELECT * FROM `scores`");

while (
$r mysql_fetch_object($result)) 


echo 
"<table width=\"100%\" border=\"1\">";
echo
"<td width=\"15%\">$r->username</td>";
echo
"<td width=\"15%\">$r->song</td>";
echo
"<td width=\"15%\">$r->Score</td>";
echo
"<td width=\"15%\">$r->instrument</td>";
echo
"<td width=\"15%\">$r->Percent%</td>";
echo
"</tr></table>";

}
?>
 


</body>
</html>


Arantor

Now, I've removed your login and password details (again) for your protection, I'll take a look.

You don't need to create a new table for every row, you just put that in a <tr> not a full new table.

Otherwise not a bad start.

calthephenom

actually, it fried my forum >_>
luckily i have a backup of my forum

Arantor

"Fried" your forum?

Then something else is wrong with your setup.


Arantor

You've modified index.template.php and it now has an error.

You're not supposed to issue DB queries inside templates (ever), and additionally even if you did, you wouldn't use your own instance of mysql_connect or mysql_query.

calthephenom

well luckily i have a bakup on my server, i'll just move the files

Mick.

Did you ever make it to work?   I'd like to see a demo. :P

calthephenom

yeh, but im still fixing it

calthephenom

Hey Arantor, could you help me with the is logged part, whenever i try it i get php parse errors, heres my current code

<form name="input" action="http://calthephenom.northeast-networks.net/insert.php" method="post">
<?php require("../SSI.php"); ?>
<center><h2><?php echo $context["user"]['name'];?></h2>
<h2><center><input type="<?php echo $context["user"]['name'];?> " name="username" /></h2></h2>
  <td class="right">
   <select class="other" name="song" id="q10"  onblur="validate(this,'Required')"  >
    <option> “Let There Be Rock” </option>
    <option> Girl’s Not Grey” </option>
    <option> You Oughta Know” </option>
    <option> “Man in the Box” </option>
    <option> Ramblin’ Man” </option>
    <option> “Almost Easy” </option>
    <option> Shooting Star” </option>
    <option> So Whatcha Want” </option>
    <option> E-Pro” </option>
    <option> “Rebel Girl” </option>
    <option> “White Wedding Pt. I” </option>
    <option> “One Way or Another” </option>
    <option> Tangled Up in Blue” </option>
    <option> “Livin’ on a Prayer” </option>
    <option> “Hello There” </option>
    <option> Uncontrollable Urge” </option>
    <option> Feel the Pain” </option>
    <option> “Down with the Sickness” </option>
    <option> “Panic Attack” </option>
    <option> “Hungry Like the Wolf” </option>
    <option> “Pump It Up” </option>
    <option> Go Your Own Way” </option>
    <option> “Everlong”</option>
    <option> Shackler’s Revenge” </option>
    <option> “PDA” </option>
    <option> Mountain Song” </option>
    <option> Aqualung” </option>
    <option> The Middle” </option>
    <option> “Bad Reputation” </option>
    <option> “Anyway You Want It” </option>
    <option> “Painkiller” </option>
    <option> “Carry On Wayward Son” </option>
    <option> Pretend We’re Dead” </option>
    <option> “Our Truth” </option>
    <option> One Step Closer” </option>
    <option> “My Own Worst Enemy” </option>
    <option> “De-Luxe” 1990’s</option>
    <option> “Colony of Birchmen” </option>
    <option> Peace Sells” </option>
    <option> “Battery” </option>
    <option> “Where’d You Go” </option>
    <option> “Float On” </option>
    <option> “Ace of Spades” </option>
    <option> Nirvana “Drain You” </option>
    <option> “Spirit in the Sky” </option>
    <option> “Nine in the Afternoon” </option>
    <option> “That’s What You Get” </option>
    <option> Alive” </option>
    <option> “Lump” </option>
    <option> “Testify” </option>
    <option> Round & Round” </option>
    <option> “Give it Away” </option>
    <option> Give it All” </option>
    <option> Rush “The Trees” </option>
    <option> Lazy Eye” </option>
    <option> “Today” </option>
    <option> I Was Wrong” </option>
    <option> “Teenage Riot” </option>
    <option> “Spoonman” </option>
    <option> Cool for Cats” </option>
    <option> “Bodhitsattva” </option>
    <option> “Rock’n Me” </option>
    <option> “Eye of the Tiger” </option>
    <option> Chop Suey” </option>
    <option> “Psycho Killer” </option>
    <option> Master Exploder” </option>
    <option> “Souls of Black” </option>
    <option> “New Kid in School” </option>
    <option> We Got the Beat” </option>
    <option> “Alabama Getaway” </option>
    <option> “American Woman” </option>
    <option> “Kids in America” </option>
    <option> “Come Out & Play (Keep ‘em Separated)” </option>
    <option> Alex Chilton” </option>
    <option> “Pinball Wizard” </option>
    <option> “Visions” </option>
    <option> “Get Clean” </option>
    <option> “Night Lies” </option>
    <option> “Shoulder to the Plow” </option>
    <option> “Welcome To The Neighborhood” </option>
    <option> “A Jagged Gorgeous Winter” </option>
    <option> Conventional Lover” </option>
    <option> Supreme Girl” </option>
    <option> Rob the Prez-O-Dent” </option>
   </select>
<center>"Instrument:"
<center><input type="text" name="instrument" />
<center>"Percent"
<center><input type="text" name="percent" />
<center><input type="submit" value="Submit" />
</form>


Arantor

So where are you getting the parse error? What error do you get exactly?

Advertisement: