doodlebug Posted April 28, 2006 Share Posted April 28, 2006 Hi Board,I am a newbie to php mysql (hence the posting in this forum). I have done a tiny snippet of code....that does not work, surprise, surprise!!!!Here's the code[code]<?//connect to mysql//change user and password to your mySQL name and passwordmysql_connect("localhost","username","password"); //select which database you want to editmysql_select_db("dbase name"); $result = my_sql query(SELECT COUNT(DISTINCT user_id)); AS how_many_users_have_predicted FROM plpredictionsdata$result = my_sql query(SELECT COUNT(user_id)); AS total_usersFROM pluserdata{ $title=$r["pluserdata"]; $who=$r["plpredictionsdata"]; echo "$title <br> users have predicted out of <br> $who ";}?>[/code]The table names are 'plpredictionsdata' & 'pluserdata', and i want it to parse a string like the last line on the code (above). One problem is that the table 'plpredictionsdata' currently has 48 lines per user (hence the (DISTINCT user_id)), but i keep getting :Parse error: syntax error, unexpected T_STRING in /xxxxx/xxxxxxx/public_html/PredictionLeague/test.php on line 9Any ideas where i have gone wrong? Quote Link to comment Share on other sites More sharing options...
sanfly Posted April 28, 2006 Share Posted April 28, 2006 Try this for startersin the two occasions where you have this[code]my_sql query[/code]Replace with this:[code]mysql_query[/code] Quote Link to comment Share on other sites More sharing options...
doodlebug Posted April 28, 2006 Author Share Posted April 28, 2006 Oooops, that was quite an obvious error, changed it, but i still get the same error message:Parse error: syntax error, unexpected T_STRING in /xxxxx/xxxxxxx/public_html/PredictionLeague/test.php on line 9 Quote Link to comment Share on other sites More sharing options...
sanfly Posted April 28, 2006 Share Posted April 28, 2006 Try This. I assume that you are replacing username, password and dbase_name with the appropriate values in the script you are actually running.....[code]//connect to mysql//change user and password to your mySQL name and passwordmysql_connect("localhost","username","password"); //select which database you want to editmysql_select_db("dbase_name");$result = mysql_query("SELECT COUNT(DISTINCT user_id) AS how_many_users_have_predictedFROM plpredictionsdata");$result = mysql_query("SELECT COUNT(user_id) AS total_usersFROM pluserdata");{ $title=$r["pluserdata"]; $who=$r["plpredictionsdata"]; echo "$title <br> users have predicted out of <br> $who ";}[/code] Quote Link to comment Share on other sites More sharing options...
doodlebug Posted April 28, 2006 Author Share Posted April 28, 2006 Yes, you are right in your assumption, i removed them from the post....sorry, should have mentioned that.Ok, i have amended the code as per the previous post, bow i get an output but it's not parsing the database information in to it. The output can be viewed here [a href=\"http://football-prediction-league.a22.biz/PredictionLeague/test.php\" target=\"_blank\"]http://football-prediction-league.a22.biz/...League/test.php[/a]As i see it, it is connecting to the database ok, running the script ok, but not generating the required results.Any other ideas??P.S. Thanks for your help already, much appreciated Quote Link to comment 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.