php and sql not updating

Please help, been at this for a month now.

A few lines before i selected a table and view the scores, It should then update the table, it then worked fine and updated the scores fine. If i copy the sql it updates tables fine in sql admin area so the sql is fine. Its the php is not working.
Ive checked the password, it connects and list scores using sql and php but will not update the table, but a few lines after it update the scores in a different table.

Here is my problem code:
[php]
$fixtures_sql33="";
$fixtures_sql33=$fixtures_sql33.“update teamplus set TPB=’”.$str_numbers_only."’ WHERE Ltrim(Rtrim(team)) like ‘%".trim($res_tabxxnam[1])."%’ and league=’".$lg."’ and Season=’".$season."’ limit 1; “;
echo $fixtures_sql33.”
";
$fixtures_res33 = mysqli_query($cxn,$fixtures_sql33) or die(mysqli_error($cxn));
[/php]
Details on the screen.
update teamplus set TPB=‘5’ WHERE Ltrim(RTrim(team)) like ‘%Hertford%’ and league=‘Nat League 3 London South East’ and Season=‘2016-2017’ limit 1;
update teamplus set TPB=‘6’ WHERE Ltrim(RTrim(team)) like ‘%Wimbledon%’ and league=‘Nat League 3 London South East’ and Season=‘2016-2017’ limit 1;
update teamplus set TPB=‘4’ WHERE Ltrim(RTrim(team)) like ‘%Tonbridge Juddian%’ and league=‘Nat League 3 London South East’ and Season=‘2016-2017’ limit 1;
update teamplus set TPB=‘3’ WHERE Ltrim(RTrim(team)) like ‘%Westcombe Park%’ and league=‘Nat League 3 London South East’ and Season=‘2016-2017’ limit 1;
update teamplus set TPB=‘4’ WHERE Ltrim(RTrim(team)) like ‘%Guernsey%’ and league=‘Nat League 3 London South East’ and Season=‘2016-2017’ limit 1;

At the moment i copy the sql to admin and update the table manually.

Please help its driving me nuts.

Not sure why you are trimming column names.
[php]
update teamplus set TPB=‘5’ WHERE Ltrim(RTrim(team)) like ‘%Hertford%’ and league=‘Nat League 3 London South East’ and Season=‘2016-2017’ limit 1;[/php]

That isn’t trimming a value. Next, why ltrim and rtrim? trim() covers both sides.

I ran a test based off of that, and either what you are using to update is different than what is posted, or something is seriously screwy with your database. You should be getting an error with the specific update queries you posted.

[php]
update teamplus set TPB=‘5’ WHERE team like ‘%Hertford%’ and league=‘Nat League 3 London South East’ and Season=‘2016-2017’ limit 1;[/php]

Lastly, You need to properly use the prepared statement.

Thanks for the reply, Im getting the data from an other website and its a bit messy.

The thing that i find strange is the sql runs and updates fine in the sql admin when i copy the sql from the webpage to the admin. So i keep pointing at the php. I tried with out the trim, with the trim, only thing that comes to mind if a special letter is in the name and when i copy and paste it the letter is not copied when i paste it to admin. I will now test my idea.

The sql before runs, and the second sql after runs and updates just the update list is not used but gets echoed to the screen and no errors on sql, php or server.

Thanks and ill keep looking, the only thing i can see is the trim, but why dose it work in admin?
:slight_smile:

Hi, Thanks for checking the code.

I fixed it after a month.

$string = trim(preg_replace(’/ +/’, ’ ‘, preg_replace(’/[^A-Za-z0-9 ]/’, ’ ', urldecode(html_entity_decode(strip_tags($string))))));

This removed any funny characters i could not see but would not copy and paste.

Pain in the butt , but now fixed :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service