Jump to content

BrandonLayton

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

BrandonLayton's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. ok... I understand now. Thanks for all of your help Extremely appreciated.
  2. This is my attempt: <?php public static function chooseGiftee($SS){ $done = false; $sqllink= mysql_connect($mysql_host,$mysql_user,$mysql_password); if(!$sqllink){ echo "Could not connect! Please Try Again"; mysql_close($sqllink); } else { $selectGiftee = "SELECT * FROM SecretSantas ORDER BY RAND() WHERE 'Gifter' = '' LIMIT 0,10"; $results = mysql_query($selectGiftee); $row=mysql_fetch_array($result) if(!$row['Gifter']=''){ $done=false; } else { $gifteeResults = $row['Name']; $addSS = "INSERT INTO SecretSantas (Gifter) VALUES ('" .$SS. "')"; $done=true; return $gifteeResults; } } mysql_close($sqllink); } ?> Error: Parse error: syntax error, unexpected T_PUBLIC in /home/a8152576/public_html/SecretSanta.html on line 14 That is on this line: public static function chooseGiftee($SS){ Little confused about why its saying it shouldn't be public.
  3. Ok thanks for the reply. Oops. Shouldn't have $results in the loop... and that loop should be an if statement if I am correct this time The purpose of the while loop is to make sure that the row does not already have a value for 'Gifter'. Not sure how else I can do that. As you can probably tell I am pretty new to php...
  4. This is my error: Fatal error: Can't use function return value in write context in /home/a8152576/public_html/SecretSanta.html on line 41 confused about why. This is the line 41: if(isset($_POST('submit')){ this is the php of my page (without the mysql data): <?php class functions{ public static function chooseGiftee($SS){ $done = false; while($done=false){ $sqllink= mysql_connect($mysql_host,$mysql_user,$mysql_password); if(!$sqllink){ echo "Could not connect! Please Try Again"; mysql_close($sqllink); } else { $selectGiftee = "SELECT * FROM SecretSantas ORDER BY RAND() LIMIT 0,10;"; while($row=mysql_fetch_array($result)){ $results = mysql_query($selectGiftee); if(!$row['Gifter']=''){ $done=false; } else { $gifteeResults = $row['Name']; $addSS = "INSERT INTO SecretSantas (Gifter) VALUES ('" .$SS. "')"; $done=true; return $gifteeResults; } } } mysql_close($sqllink); } } } if(isset($_POST('submit')){ $echoName = functions::chooseGiftee($_POST['gifterName']); echo $echoName; } ?> This is html: <form id="form1" name="form1" method="post" action=""> <p> <label>Your Name: <input type="text" name="gifterName" id="gifterName" /> </label> <input type="submit" name="submit" id="submit" value="Submit" /> </p> <p> </p> </form> Confused about the issue, first time using functions. Thanks in advance, Brandon
  5. Wow. gosh I need to check stuff like that a little better. Thanks Ok, only used php a few times so not advanced enough to really know that I guess xD Thanks a lot
  6. For some reason this code is not changing anything in the database. I am 99% sure I am typing in the right info into the text boxes, and even if I wasn't it should give me error messages. Kinda stumped. Hopefully a new pair of eyes can help. <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Member System Install</title> </head> <body> <form id="form1" name="form1" method="post" action=""> <h2><center>Fill in the following info properly to install required databases.</center></h2> <p> <label>Host: <input type="text" name="host" id="host" /> </label> </p> <p> <label>Database User: <input type="text" name="dbUser" id="dbUser" /> </label> </p> <p> <label>Database Password: <input type="text" name="dbPass" id="dbPass" /> </label> </p> <p> <label>Desired Admin Username: <input type="text" name="adminName" id="adminName" /> </label> </p> <p> <label>Desired Admin Password: <input type="text" name="adminPass" id="adminPass" /> </label> </p> <p> <label>Email: <input type="text" name="adminEmail" id="adminEmail" /> </label> </p> <p> <input type="submit" name="submitBtn" id="submitBtn" value="Submit" /> </p> </form> <?php if(isset($_POST['submit'])){ $hostName = $_POST['host']; $dbUserName = $_POST['dbUser']; $dbPassword = $_POST['dbPass']; $adminUserName = $_POST['adminName']; $adminPassword = $_POST['adminPass']; $email = $_POST['adminEmail']; $sqlLink = mysql_connect('$hostName','$dbUserName','$dbPassword'); if(!$sqlLink){ die('Could not connect: ' .mysql_error()); mysql_close(); } else { $queryCreate = 'CREATE DATABASE member_db'; echo 'Connected successfully!'; if(mysql_query($queryCreate,$link)){ echo 'Created database!'; mysql_select_db('member_db'); $createAdminTable = "CREATE TABLE " .$adminUserName. " (`secLvl` tinyint(1) default NOT NULL,`rank` tinyint(2) default NOT NULL,`username` varChar(32) NOT NULL UNIQUE,`password` varChar(32) NOT NULL,`email` varChar(32) NOT NULL UNIQUE"; $insertAdminInfoQuery = "UPDATE " .$adminUserName. " SET `secLvl` = '5', `rank` = '10', `username` = '$adminUserName', `password` = '$adminPassword', `email` = '$email' WHERE '$adminUserName' LIMIT 1"; mysql_query($createAdminTable) or die("ERROR: " .mysql_error()); mysql_query($insertAdminInfoQuery) or die("ERROR: " .mysql_error()); } else { echo 'Error: '.mysql_error(); } } } ?> </body> </html> Thanks, Brandon
  7. Wow. Haha thanks. I feel a little stupid now but it works edit: Well now it shows up, but when I try to submit everything just clears. Nothing echos to confirm or deny that it works and now database is created. So i am a little confounded <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Member System Install</title> </head> <body> <form id="form1" name="form1" method="post" action=""> <h2><center>Fill in the following info properly to install required databases.</center></h2> <p> <label>Host: <input type="text" name="host" id="host" /> </label> </p> <p> <label>Database User: <input type="text" name="dbUser" id="dbUser" /> </label> </p> <p> <label>Database Password: <input type="text" name="dbPass" id="dbPass" /> </label> </p> <p> <label>Desired Admin Username: <input type="text" name="adminName" id="adminName" /> </label> </p> <p> <label>Desired Admin Password: <input type="text" name="adminPass" id="adminPass" /> </label> </p> <p> <label>Email: <input type="text" name="adminEmail" id="adminEmail" /> </label> </p> <p> <input type="submit" name="submitBtn" id="submitBtn" value="Submit" /> </p> </form> <?php if(isset($_POST['submit'])){ $hostName = $_POST['host']; $dbUserName = $_POST['dbUser']; $dbPassword = $_POST['dbPass']; $adminUserName = $_POST['adminName']; $adminPassword = $_POST['adminPass']; $email = $_POST['adminEmail']; $sqlLink = mysql_connect('$hostName','$dbUserName','$dbPassword'); if(!$sqlLink){ die('Could not connect: ' .mysql_error()); mysql_close(); } else { $queryCreate = 'CREATE DATABASE member_db'; echo 'Connected successfully!'; if(mysql_query($queryCreate,$link)){ echo 'Created database!'; mysql_select_db('member_db'); $createAdminTable = "CREATE TABLE " .$adminUserName. " (`secLvl` tinyint(1) default NOT NULL,`rank` tinyint(2) default NOT NULL,`username` varChar(32) NOT NULL UNIQUE,`password` varChar(32) NOT NULL,`email` varChar(32) NOT NULL UNIQUE"; $insertAdminInfoQuery = "UPDATE " .$adminUserName. " SET `secLvl` = '5', `rank` = '10', `username` = '$adminUserName', `password` = '$adminPassword', `email` = '$email' WHERE '$adminUserName' LIMIT 1"; mysql_query($createAdminTable) or die("ERROR: " .mysql_error()); mysql_query($insertAdminInfoQuery) or die("ERROR: " .mysql_error()); } else { echo 'Error: '.mysql_error(); } } } ?> </body> </html>
  8. My first real attempt to mess with MySql. Keep getting a syntax error and I am quite confused. Error: Parse error: syntax error, unexpected '}' in /home/a8152576/public_html/MemberSystem/install1.php on line 68 Here is my php code: <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form id="form1" name="form1" method="post" action=""> <h2><center>Fill in the following info properly to install required databases.</center></h2> <p> <label>Host: <input type="text" name="host" id="host" /> </label> </p> <p> <label>Database User: <input type="text" name="dbUser" id="dbUser" /> </label> </p> <p> <label>Database Password: <input type="text" name="dbPass" id="dbPass" /> </label> </p> <p> <label>Desired Admin Username: <input type="text" name="adminName" id="adminName" /> </label> </p> <p> <label>Desired Admin Password: <input type="text" name="adminPass" id="adminPass" /> </label> </p> <p> <label>Email: <input type="text" name="adminEmail" id="adminEmail" /> </label> </p> <p> <input type="submit" name="submitBtn" id="submitBtn" value="Submit" /> </p> </form> <?php if(isset($_POST['submit'])){ $hostName = $_POST['host']; $dbUserName = $_POST['dbUser']; $dbPassword = $_POST['dbPass']; $adminUserName = $_POST['adminName']; $adminPassword = $_POST['adminPass']; $email = $_POST['adminEmail']; $sqlLink = mysql_connect('$hostName','$dbUserName','$dbPassword'); if(!$sqlLink){ die('Could not connect: ' .mysql_error()); mysql_close(); } else { $queryCreate = 'CREATE DATABASE member_db'; echo 'Connected successfully!'; if(mysql_query($queryCreate,$link)){ echo 'Created database!'; mysql_select_db('member_db'); $createAdminTable = "CREATE TABLE " .$adminUserName. " (`secLvl` tinyint(1) default NOT NULL,`rank` tinyint(2) default NOT NULL,`username` varChar(32) NOT NULL UNIQUE,`password` varChar(32) NOT NULL,`email` varChar(32) NOT NULL UNIQUE"; $insertAdminInfoQuery = "UPDATE " .$adminUserName. " SET `secLvl` = '5', `rank` = '10', `username` = '$adminUserName', `password` = '$adminPassword', `email` = '$email' WHERE '$adminUserName' LIMIT 1"; mysql_query($createAdminTable) or die("ERROR: " .mysql_error()); mysql_query($insertAdminInfoQuery) or die("ERROR: " .mysql_error()) } else { echo 'Error: '.mysql_error(); } } } ?> </body> </html> You can even see the error on this web page directly: http://www.ptcptc.info/MemberSystem/install1.php Thanks, Brandon
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.