wayneglossop Posted November 12, 2013 Share Posted November 12, 2013 Hi. New to this forum and desperately need help! I have just migrated my database info from MySQL4 to MySQL5. The pages can connect to the database, but it doesn't show the info in the tables, saying there's a syntax error. Is there a problem using "mysql_query" in MySQL5, and can I just replace it with something so it'll work?? (I have a lot of mysql_query's in my coding)! Cheers, Wayne. Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted November 12, 2013 Share Posted November 12, 2013 (edited) The pages can connect to the database, but it doesn't show the info in the tables, saying there's a syntax error. What is the syntax error you are getting? Is there a problem using "mysql_query" in MySQL5, and can I just replace it with something so it'll work?? No. But if you're using PHP5 then it is recommend to use the mysql improved function library instead of the standard mysql function (mysql_*) library as these are now deprecated. Edited November 12, 2013 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
wayneglossop Posted November 12, 2013 Author Share Posted November 12, 2013 Thanks for reply. Here is the error message: Error performing query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Div='2' ORDER BY L_Name ASC, F_Name ASC' at line 1 Is there a problem with quotation marks or apostrophes? Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted November 12, 2013 Share Posted November 12, 2013 It is because Div is a reserved keyword in MySQL5. Edit your query and wrap it in backticks so Div='2' becomes `Div`='2' Quote Link to comment Share on other sites More sharing options...
wayneglossop Posted November 12, 2013 Author Share Posted November 12, 2013 ooooh. Sounds promising! Will give it a try…. Quote Link to comment Share on other sites More sharing options...
wayneglossop Posted November 12, 2013 Author Share Posted November 12, 2013 Success! Thank you very much Ch0cu3r. You're a star! Wayne. Quote Link to comment Share on other sites More sharing options...
wayneglossop Posted January 12, 2014 Author Share Posted January 12, 2014 Hi Again! I'm having problems with more coding, which may be linked to the "Div" situation: Do you know if there would be a problem with $div as well? Do I need to change it to $`div` ? Wayne. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted January 12, 2014 Share Posted January 12, 2014 a) you somehow marked your last post as being the post that solved the thread. b) we cannot tell you what is wrong with your code unless you post your code and tell us what sort of problem or error you having with that code. Quote Link to comment Share on other sites More sharing options...
wayneglossop Posted January 12, 2014 Author Share Posted January 12, 2014 a) Sorry. Didn't know if I had to click it to make it "unsolved". b) Here is a snippet of code, though I realise you may need more: mysql_query("UPDATE $tablename SET `Div`='$div', HomeTeam='".$team01['HomeTeam']."', Sets_Home='0', AwayTeam='".$team02['HomeTeam']."', Sets_Away='0', Posted_On='', Posted_By='' WHERE Match_No='1'"); The team names are not being entered into the database. Wayne. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted January 12, 2014 Share Posted January 12, 2014 you would need to determine why the two php variables holding those values don't have the expected contents. it's also possible that the code where that UPDATE query is at isn't even being executed and you are only seeing the initial values that have been INSERTED into the table. the query you posted also hints at an application that is poorly designed, resulting in a huge amount of code. why do i state that. it's an UPDATE query with a hard-coded value in the where clause. you would normally only UPDATE existing data to alter values or correct errors in previously entered data and each field would have the possibility of being edited/updated. there would also be the possibility of specifying the row corresponding to any match number. that's not what this query is showing, so i suspect that at some point blank rows are being inserted for each possible match number into a unique table for each new season, then someone goes through editing/updating every row with the division, HomeTeam, and AwayTeam, with code repeated for each hard-coded match number? if so, there's a huge amount of unneeded code. Quote Link to comment Share on other sites More sharing options...
wayneglossop Posted January 12, 2014 Author Share Posted January 12, 2014 I realise there is way too much code for what I require and is probably very poorly designed, but I was a rank amateur when I first made my website, and I'm not much better now! All I know is the code was working before I had to migrate to the latest MySql database, which is very annoying. The "Div" situation has solved part of the problem, but doesn't seem to have had the same effect with this one. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted January 12, 2014 Share Posted January 12, 2014 your reply indicates you did not or cannot perform this basic debugging - you would need to determine why the two php variables holding those values don't have the expected contents. it's also possible that the code where that UPDATE query is at isn't even being executed and you are only seeing the initial values that have been INSERTED into the table. i'm afraid there's not much that we can do for you based on just the end symptom. in programming, because there are multiple different ways of accomplishing any task, there is not a 'one symptom' has exactly a 'one cause' relationship. there is at least a dozen different things that could cause any one query or code to not operate as expected when moving between different server configurations or different server versions and we don't have any information in this thread that would narrow down the problem by eliminating any of those possibilities. the only additional thing that comes to mind is the posted query could be executing with the expected values in it, but it is failing due to an error. have you tried adding some error checking logic to the query that would give you the mysql_error() output? 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.