Yeh, didn't use foobar. Where does foobar come from? And that ipse lorum ... or something like that you always see in examples. I always use rude words in my test data, much easier. Anyway, thanks again.
- Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
- Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Any PHP mysqli experts?
Collapse
X
-
bloggoth
If everything isn't black and white, I say, 'Why the hell not?'
John Wayne (My guru, not to be confused with my beloved prophet Jeremy Clarkson) -
Originally posted by xoggoth View PostWhere does foobar come from?
(Or a corruption of fubar )
Comment
-
Originally posted by xoggoth View PostAh! I didn't see the relevance of your comment initially but you've sorted it for me, I just updated each item individually and it worked.
$sql = $con->query("UPDATE whlist SET date='$date' WHERE id=$id");
$sql = $con->query("UPDATE whlist SET title='$title' WHERE id=$id");
$sql = $con->query("UPDATE whlist SET speaker='$speaker' WHERE id=$id");
$sql = $con->query("UPDATE whlist SET description='$description' WHERE id=$id");
$con->error still showing same error message but I'll just comment that out.
Thanks woody1
Can't understand why I never had this problem before in my business website, got lots of far more complicated update lines. Maybe some property of the table?
Also how are the $vars sanitized? What if $id became "1; DELETE FROM whlist"?Comment
-
Cheers TGB. I do sanitise, remove quotes etc, and check if update worked but didn't put those lines here to keep it simple. As per post I would normally do a single update line but not working here for some reason, my flaky aproach only one that worked. Not a site of any importance anyway.
PS Not quite sure what atomic is, have to have a Google.
PPS Nice cartoon. xkcd: Exploits of a MomLast edited by xoggoth; 31 July 2023, 10:46.bloggoth
If everything isn't black and white, I say, 'Why the hell not?'
John Wayne (My guru, not to be confused with my beloved prophet Jeremy Clarkson)Comment
-
Originally posted by TheGreenBastard View PostThat's a pretty flaky approach, inefficient and no transactional integrity, what happens if the date update works but title doesn't? Do it as a single atomic UPDATE.
Comment
-
You said your solution is working? Are you sure it is? ie. is it actually inserting the values of variables $date, $title etc, or is it inserting the string values "$date", "$title" etc.
Here's what i think it should be (typed from memory, not tested). The {} inserts the variables into the query string.
PHP Code:$sql = $con->query("UPDATE whlist SET date='{$date}', title='{$title}', speaker='{$speaker}', description='{$description}'
WHERE id={$id}");
The above assumes id is numeric key, otherwise
PHP Code:$sql = $con->query("UPDATE whlist SET date='{$date}', title='{$title}', speaker='{$speaker}', description='{$description}'
WHERE id='{$id}'");
If you're still getting errors, do
PHP Code:print_r($sql);
To show you what the raw SQL being executed is.Last edited by Paralytic; 31 July 2023, 14:27.Comment
-
Thanks all but no need for any more solutions, it's just a little local history website, form will only be used by me and maybe 2 other people. Working ok at mo.
I do have a much more complicated small businesss website with checkout, one of the lines here, (daddress = sanitised version of address etc.) works fine:
$sql = $con->query("UPDATE shop SET name='$dname',school='$dschool',address='$daddress ',postcode='$postcode',country='$country',
tel='$tel',email='$email',comment='$dcomment' WHERE custid = '$custid'");
if ($sql === FALSE)
{
echo "Error: " . $sql . "<br>" . $con->error;
echo "Update cust 1 failed";
}
Just that that aproach with multiple items did not work in the little history thing, dunno why.Last edited by xoggoth; 31 July 2023, 20:29.bloggoth
If everything isn't black and white, I say, 'Why the hell not?'
John Wayne (My guru, not to be confused with my beloved prophet Jeremy Clarkson)Comment
-
Originally posted by xoggoth View PostPS Not quite sure what atomic is, have to have a Google.When the fun stops, STOP.Comment
-
Originally posted by HoofHearted View PostSee You Next TuesdayComment
- Home
- News & Features
- First Timers
- IR35 / S660 / BN66
- Employee Benefit Trusts
- Agency Workers Regulations
- MSC Legislation
- Limited Companies
- Dividends
- Umbrella Company
- VAT / Flat Rate VAT
- Job News & Guides
- Money News & Guides
- Guide to Contracts
- Successful Contracting
- Contracting Overseas
- Contractor Calculators
- MVL
- Contractor Expenses
Advertisers
Contractor Services
CUK News
- Streamline Your Retirement with iSIPP: A Solution for Contractor Pensions Sep 1 09:13
- Making the most of pension lump sums: overview for contractors Sep 1 08:36
- Umbrella company tribunal cases are opening up; are your wages subject to unlawful deductions, too? Aug 31 08:38
- Contractors, relabelling 'labour' as 'services' to appear 'fully contracted out' won't dupe IR35 inspectors Aug 31 08:30
- How often does HMRC check tax returns? Aug 30 08:27
- Work-life balance as an IT contractor: 5 top tips from a tech recruiter Aug 30 08:20
- Autumn Statement 2023 tipped to prioritise mental health, in a boost for UK workplaces Aug 29 08:33
- Final reminder for contractors to respond to the umbrella consultation (closing today) Aug 29 08:09
- Top 5 most in demand cyber security contract roles Aug 25 08:38
- Changes to the right to request flexible working are incoming, but how will contractors be affected? Aug 24 08:25
Comment