Jayden_Blade Posted November 25, 2013 Share Posted November 25, 2013 Hello again! having an error issue. Parse error: syntax error, unexpected 'DISTINCT' (T_STRING) in /home/jayden1/public_html/newmembers.php on line 91 <?php $year = (date('Y')); $month = (date('m')); $day = date(('d')- 30); $datecheck = mktime(0,0,0,$month,$day,$year); $new = $mysqli->query(SELECT DISTINCT signupdate FROM profiledata); $signupdate = $new; if(mysql_num_rows($signupdate)>0){ print "<ul>"; while($users=mysql_fetch_array($signupdate)){ print "<li>{$users[0]}</li>"; } ?> i have went through it like 100 times. I know i am missing something somewhere. Anyone know what I forgot? Quote Link to comment https://forums.phpfreaks.com/topic/284253-parse-error-syntax-error-unexpected-distinct-t_string-in/ Share on other sites More sharing options...
gristoi Posted November 25, 2013 Share Posted November 25, 2013 wrap your query in quotes: $new = $mysqli->query("SELECT DISTINCT `signupdate` FROM `profiledata`"); Quote Link to comment https://forums.phpfreaks.com/topic/284253-parse-error-syntax-error-unexpected-distinct-t_string-in/#findComment-1459939 Share on other sites More sharing options...
Jayden_Blade Posted November 25, 2013 Author Share Posted November 25, 2013 Parse error: syntax error, unexpected end of file in /home/jayden1/public_html/newmembers.php on line 135 New error? <?php session_start(); if (!$_SESSION || !$_SESSION['login']) { //redirect to a login page header('Location: index.php'); exit; } ?> <html> <head> <link type="text/css" rel="stylesheet" href="style.css" /> </head> <body> <div id="info_wrapper"> <table align="center" width="1100px"> <tr> <td width="220px" align="center"> <a href="home.php">Home</a> </td> <td width="220px" align="center"> <a href="myhome.php">My Home Page</a> </td> <td width="220px" align="center"> <a href="profile.php">My Profile</a> </td> <td width="220px" align="center"> <a href="msearch.php">Member Search</a> </td> <td width="220px" align="center"> <a href="logout.php">Logout</a> </td> </tr> </table> </br> <table align="center" width="1100px"> <tr> <td width="366px" align="center"> <a href="missionstatement.php">Mission Statement</a> </td> <td width="366px" align="center"> <a href="adviceblog.php">Advice Blog</a> </td> <td width="366px" align="center"> <a href="storycorner.php">Story Corner</a> </td> </tr> </table> </br></br></br> <h2 id="h2" align="center"> New Members </h2> </br></br> <?php $year = (date('Y')); $month = (date('m')); $day = date(('d')- 30); $datecheck = mktime(0,0,0,$month,$day,$year); $new = $mysqli->query("SELECT DISTINCT signupdate FROM profiledata"); $signupdate = $new; if(mysql_num_rows($signupdate)>0){ print "<ul>"; while($users=mysql_fetch_array($signupdate)){ print "<li>{$users[0]}</li>"; } ?> </br></br> <p chat> Instant Messages and Online friends here </p chat> </br></br></br> <table align="center" width="1100px"> <tr> <td> <a href="tos.php">Terms of Service</a> </td> <td> <a href="suggestionbox.php">Suggestion Box</a> </td> </tr> <tr> <td> <a href="privacy.php">Privacy Policy</a> </td> <td> <a href="problem.php">Report a Problem</a> </td> </tr> <tr> <td> <a href="contact.php">Contact Us</a> </td> </tr> </table> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/284253-parse-error-syntax-error-unexpected-distinct-t_string-in/#findComment-1459946 Share on other sites More sharing options...
Ch0cu3r Posted November 25, 2013 Share Posted November 25, 2013 (edited) You have left of the closing brace on line 98 (highlighted in red below) if(mysql_num_rows($signupdate)>0){ print "<ul>"; while($users=mysql_fetch_array($signupdate)){ print "<li>{$users[0]}</li>"; } } // <--- add this closing brace on line 98 Also you will want to echo out the closing list tag </li> after the while loop so your HTML has valid syntax. Having invalid HTML syntax could result in unexpected behaviour in different browsers. Edited November 25, 2013 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/284253-parse-error-syntax-error-unexpected-distinct-t_string-in/#findComment-1459950 Share on other sites More sharing options...
Jayden_Blade Posted November 25, 2013 Author Share Posted November 25, 2013 (edited) Fatal error: Call to a member function query() on a non-object in /home/jayden1/public_html/newmembers.php on line 91 <?php session_start(); if (!$_SESSION || !$_SESSION['login']) { //redirect to a login page header('Location: index.php'); exit; } ?> <html> <head> <link type="text/css" rel="stylesheet" href="style.css" /> </head> <body> <div id="info_wrapper"> <table align="center" width="1100px"> <tr> <td width="220px" align="center"> <a href="home.php">Home</a> </td> <td width="220px" align="center"> <a href="myhome.php">My Home Page</a> </td> <td width="220px" align="center"> <a href="profile.php">My Profile</a> </td> <td width="220px" align="center"> <a href="msearch.php">Member Search</a> </td> <td width="220px" align="center"> <a href="logout.php">Logout</a> </td> </tr> </table> </br> <table align="center" width="1100px"> <tr> <td width="366px" align="center"> <a href="missionstatement.php">Mission Statement</a> </td> <td width="366px" align="center"> <a href="adviceblog.php">Advice Blog</a> </td> <td width="366px" align="center"> <a href="storycorner.php">Story Corner</a> </td> </tr> </table> </br></br></br> <h2 id="h2" align="center"> New Members </h2> </br></br> <?php $year = (date('Y')); $month = (date('m')); $day = date(('d')- 30); $datecheck = mktime(0,0,0,$month,$day,$year); $new = $mysqli->query("SELECT DISTINCT signupdate FROM profiledata"); $signupdate = $new; if(mysql_num_rows($signupdate)>0){ print "<ul>"; while($users=mysql_fetch_array($signupdate)){ print "<li>{$users[0]}</li>"; } } ?> </br></br> <p chat> Instant Messages and Online friends here </p chat> </br></br></br> <table align="center" width="1100px"> <tr> <td> <a href="tos.php">Terms of Service</a> </td> <td> <a href="suggestionbox.php">Suggestion Box</a> </td> </tr> <tr> <td> <a href="privacy.php">Privacy Policy</a> </td> <td> <a href="problem.php">Report a Problem</a> </td> </tr> <tr> <td> <a href="contact.php">Contact Us</a> </td> </tr> </table> </div> </body> </html> Edited November 25, 2013 by Jayden_Blade Quote Link to comment https://forums.phpfreaks.com/topic/284253-parse-error-syntax-error-unexpected-distinct-t_string-in/#findComment-1459952 Share on other sites More sharing options...
Ch0cu3r Posted November 25, 2013 Share Posted November 25, 2013 So you are using $mysqli->query() without connecting to mysql. What do you think you need to do now? Also note mysqli methods/functions and mysql_* functions are not compatible. You use one or the other, not both at the same type. Quote Link to comment https://forums.phpfreaks.com/topic/284253-parse-error-syntax-error-unexpected-distinct-t_string-in/#findComment-1459955 Share on other sites More sharing options...
Jayden_Blade Posted November 25, 2013 Author Share Posted November 25, 2013 *FACE PALM* DUH I am a dumb ass some times! LOL thanks Quote Link to comment https://forums.phpfreaks.com/topic/284253-parse-error-syntax-error-unexpected-distinct-t_string-in/#findComment-1459956 Share on other sites More sharing options...
Jayden_Blade Posted November 25, 2013 Author Share Posted November 25, 2013 Hopefully the last question for a while.. Warning: mysql_num_rows() expects parameter 1 to be resource, array given in /home/jayden1/public_html/newmembers.php on line 93 <?php error_reporting(E_ALL); $year = (date('Y')); $month = (date('m')); $day = date(('d')- 30); $datecheck = mktime(0,0,0,$month,$day,$year); include ('/home/jayden1/database_access/database.php'); $new = mysql_query("SELECT DISTINCT signupdate FROM profiledata"); $signupdate = mysql_fetch_assoc($new); if(mysql_num_rows($signupdate)>0){ print "<ul>"; while($users=mysql_fetch_array($signupdate)){ print "<li>{$users[0]}</li>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/284253-parse-error-syntax-error-unexpected-distinct-t_string-in/#findComment-1459957 Share on other sites More sharing options...
Solution Ch0cu3r Posted November 25, 2013 Solution Share Posted November 25, 2013 Lines 92 to 93 above should be if(mysql_num_rows($new)>0){ Quote Link to comment https://forums.phpfreaks.com/topic/284253-parse-error-syntax-error-unexpected-distinct-t_string-in/#findComment-1459973 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.