AlmarM Posted July 6, 2008 Share Posted July 6, 2008 Hello, This is my first time on PHPFreaks.com And I have a question. Whats wrong with this: <?php $host['name'] = '86.92.129.3'; $host['username'] = 'root'; $host['password'] = ''; $host['databasename'] = 'odinms'; $db = mysql_connect($host['name'], $host['username'], $host['password']) OR die ('Cant connect to MySQL!'); mysql_select_db($host['databasename'], $db); $name = $_POST['name']; $age = $_POST['age']; $accountname = $_POST['accountname']; $experience = $_POST['experience']; $why = $_POST['why']; $sel = "SELECT * FROM accounts WHERE name='$name'"; if ($accountname == ''); { echo "Please enter a accountname!" } $d = 'INSERT INTO gmapps (name, age, accountname, experience, why' VALUES('$name', '$age', '$accountname', '$experience', '$why'); mysql_query($d) OR die (mysql_error()); echo "Your GM Application has been send!"; ?> When I use it it says: unexpected '}', expecting ',' or ';' -AlmarM- Link to comment https://forums.phpfreaks.com/topic/113447-unexpected-expecting-or/ Share on other sites More sharing options...
bothwell Posted July 6, 2008 Share Posted July 6, 2008 if ($accountname == ''); { echo "Please enter a accountname!" } When I use it it says: unexpected '}', expecting ',' or ';' -AlmarM- You're missing a semi-colon after "please enter an accountname!" Link to comment https://forums.phpfreaks.com/topic/113447-unexpected-expecting-or/#findComment-582920 Share on other sites More sharing options...
AlmarM Posted July 6, 2008 Author Share Posted July 6, 2008 Thank you I tried it and worked. But now im getting: unexpected T_STRING In line 18! <?php $host['name'] = '86.92.129.3'; $host['username'] = 'root'; $host['password'] = ''; $host['databasename'] = 'odinms'; $db = mysql_connect($host['name'], $host['username'], $host['password']) OR die ('Cant connect to MySQL!'); mysql_select_db($host['databasename'], $db); $name = $_POST['name']; $age = $_POST['age']; $accountname = $_POST['accountname']; $experience = $_POST['experience']; $why = $_POST['why']; $sel = "SELECT * FROM accounts WHERE name='$name'"; if ($accountname == ''); { echo "Please enter a accountname!"; } $d = 'INSERT INTO gmapps (name, age, accountname, experience, why' VALUES('$name', '$age', '$accountname', '$experience', '$why'); //Line 18 mysql_query($d) OR die (mysql_error()); echo "Your GM Application has been send!"; ?> What sould I do? -AlmarM- Link to comment https://forums.phpfreaks.com/topic/113447-unexpected-expecting-or/#findComment-582923 Share on other sites More sharing options...
bothwell Posted July 6, 2008 Share Posted July 6, 2008 Thank you I tried it and worked. But now im getting: unexpected T_STRING In line 18! $d = 'INSERT INTO gmapps (name, age, accountname, experience, why' VALUES('$name', '$age', '$accountname', '$experience', '$why'); //Line 18 What sould I do? -AlmarM- You're using an apostrophe just before VALUES instead of a closing brace Link to comment https://forums.phpfreaks.com/topic/113447-unexpected-expecting-or/#findComment-582925 Share on other sites More sharing options...
AlmarM Posted July 6, 2008 Author Share Posted July 6, 2008 Hmm like this? <?php $host['name'] = '86.92.129.3'; $host['username'] = 'root'; $host['password'] = ''; $host['databasename'] = 'odinms'; $db = mysql_connect($host['name'], $host['username'], $host['password']) OR die ('Cant connect to MySQL!'); mysql_select_db($host['databasename'], $db); $name = $_POST['name']; $age = $_POST['age']; $accountname = $_POST['accountname']; $experience = $_POST['experience']; $why = $_POST['why']; $sel = "SELECT * FROM accounts WHERE name='$name'"; if ($accountname == ''); { echo "Please enter a accountname!"; } $d = 'INSERT INTO gmapps (name, age, accountname, experience, why') VALUES ('$name', '$age', '$accountname', '$experience', '$why'); //Line 18 mysql_query($d) OR die (mysql_error()); echo "Your GM Application has been send!"; ?> *Trying* Arg now im getting unexpected ')' Sorry for all the questions but this is my first day with PHP -AlmarM- Link to comment https://forums.phpfreaks.com/topic/113447-unexpected-expecting-or/#findComment-582926 Share on other sites More sharing options...
papaface Posted July 6, 2008 Share Posted July 6, 2008 Should be: <?php $host['name'] = '86.92.129.3'; $host['username'] = 'root'; $host['password'] = ''; $host['databasename'] = 'odinms'; $db = mysql_connect($host['name'], $host['username'], $host['password']) OR die ('Cant connect to MySQL!'); mysql_select_db($host['databasename'], $db); $name = $_POST['name']; $age = $_POST['age']; $accountname = $_POST['accountname']; $experience = $_POST['experience']; $why = $_POST['why']; $sel = "SELECT * FROM accounts WHERE name='$name'"; if ($accountname == ''); { echo "Please enter a accountname!"; } $d = "INSERT INTO `gmapps` (`name`, `age`, `accountname`, `experience`, `why`) VALUES ($name, $age, $accountname, $experience, $why)"; mysql_query($d) OR die (mysql_error()); echo "Your GM Application has been send!"; ?> Link to comment https://forums.phpfreaks.com/topic/113447-unexpected-expecting-or/#findComment-582928 Share on other sites More sharing options...
AlmarM Posted July 6, 2008 Author Share Posted July 6, 2008 Thx, but now im getting unexpected T_STRING On line 21 <?php $host['name'] = '86.92.129.3'; $host['username'] = 'root'; $host['password'] = ''; $host['databasename'] = 'odinms'; $db = mysql_connect($host['name'], $host['username'], $host['password']) OR die ('Cant connect to MySQL!'); mysql_select_db($host['databasename'], $db); $name = $_POST['name']; $age = $_POST['age']; $accountname = $_POST['accountname']; $experience = $_POST['experience']; $why = $_POST['why']; $sel = "SELECT * FROM accounts WHERE name='$name'"; if ($accountname == ''); { echo "Please enter a accountname!"; } $d = INSERT INTO `gmapps` (`name`, `age`, `accountname`, `experience`, `why`) VALUES ($name, $age, $accountname, $experience, $why); // Line 21 mysql_query($d) OR die (mysql_error()); echo "Your GM Application has been send!"; ?> -AlmarM- Link to comment https://forums.phpfreaks.com/topic/113447-unexpected-expecting-or/#findComment-582931 Share on other sites More sharing options...
papaface Posted July 6, 2008 Share Posted July 6, 2008 thanks, but now im getting unexpected T_STRING On line 21 <?php $host['name'] = '86.92.129.3'; $host['username'] = 'root'; $host['password'] = ''; $host['databasename'] = 'odinms'; $db = mysql_connect($host['name'], $host['username'], $host['password']) OR die ('Cant connect to MySQL!'); mysql_select_db($host['databasename'], $db); $name = $_POST['name']; $age = $_POST['age']; $accountname = $_POST['accountname']; $experience = $_POST['experience']; $why = $_POST['why']; $sel = "SELECT * FROM accounts WHERE name='$name'"; if ($accountname == ''); { echo "Please enter a accountname!"; } $d = INSERT INTO `gmapps` (`name`, `age`, `accountname`, `experience`, `why`) VALUES ($name, $age, $accountname, $experience, $why); // Line 21 mysql_query($d) OR die (mysql_error()); echo "Your GM Application has been send!"; ?> -AlmarM- You didnt use my modified version. Copy it again. P.S This extremely easy stuff, you should look into the basics of PHP. Link to comment https://forums.phpfreaks.com/topic/113447-unexpected-expecting-or/#findComment-582934 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.