Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #17679 > unrolled thread
| Started by | Call Me Tom <noemail@noemail.com> |
|---|---|
| First post | 2018-02-01 00:04 -0500 |
| Last post | 2018-02-03 16:49 -0600 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.php
PDO Problem? Call Me Tom <noemail@noemail.com> - 2018-02-01 00:04 -0500
Re: PDO Problem? "Peter H. Coffin" <hellsop@ninehells.com> - 2018-02-03 16:49 -0600
| From | Call Me Tom <noemail@noemail.com> |
|---|---|
| Date | 2018-02-01 00:04 -0500 |
| Subject | PDO Problem? |
| Message-ID | <qs757d9rh00uro2nmm1kbvsshgq5tq5l9m@4ax.com> |
The logged user has all privileges on the database.
The $numin echo prints 2555 which is the number of rows in the table.
The table test is unchanged after running the file.
Here's the code.
<?php
require_once('./includes/mysql_connect.php');
$query = "SELECT report_id,fsacars_rep_url
FROM test";
$result=$dbh->query($query);
$numin=$result->rowCount();
echo "$numin";
while($url_orig=$result->FETCH(PDO::FETCH_NUM)) {
$report_id = $url_orig[0];
$url_trim = substr($url_orig[1],34);
$url_new = 'http://localhost/CAA' . $url_trim;
$sql="UPDATE test
SET fsacars_rep_url = $url_new
WHERE report_id = $report_id";
$dbh->exec($sql);
}
What am I missing?
[toc] | [next] | [standalone]
| From | "Peter H. Coffin" <hellsop@ninehells.com> |
|---|---|
| Date | 2018-02-03 16:49 -0600 |
| Message-ID | <slrnp7cf2u.d0s.hellsop@nibelheim.ninehells.com> |
| In reply to | #17679 |
On Thu, 01 Feb 2018 00:04:16 -0500, Call Me Tom wrote:
> The logged user has all privileges on the database.
> The $numin echo prints 2555 which is the number of rows in the table.
> The table test is unchanged after running the file.
> Here's the code.
Useful information here would include "what did you expect to happen",
"what actually did happen" and "what errors were put in the logging".
>
><?php
>
> require_once('./includes/mysql_connect.php');
>
> $query = "SELECT report_id,fsacars_rep_url
> FROM test";
>
> $result=$dbh->query($query);
> $numin=$result->rowCount();
> echo "$numin";
> while($url_orig=$result->FETCH(PDO::FETCH_NUM)) {
> $report_id = $url_orig[0];
> $url_trim = substr($url_orig[1],34);
> $url_new = 'http://localhost/CAA' . $url_trim;
>
> $sql="UPDATE test
> SET fsacars_rep_url = $url_new
> WHERE report_id = $report_id";
> $dbh->exec($sql);
> }
>
> What am I missing?
A bunch of stuff probably unrelated to your question for one thing.
https://xkcd.com/327/ is a start. Learn to use paremeterized prepare and
execute to help prevent that.
I think you may want some quotes around what you're setting columns to.
--
32. I will not fly into a rage and kill a messenger who brings me bad
news just to illustrate how evil I really am. Good messengers are
hard to come by.
--Peter Anspach's list of things to do as an Evil Overlord
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web