Jump to content

php coding error?


wayneglossop

Recommended Posts

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.

 

Link to comment
Share on other sites

 

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 by Ch0cu3r
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

  • 1 month later...

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.
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.