Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #17688

Re: PDO Problem?

Path csiph.com!weretis.net!feeder4.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From "Peter H. Coffin" <hellsop@ninehells.com>
Newsgroups comp.lang.php
Subject Re: PDO Problem?
Date Sat, 3 Feb 2018 16:49:02 -0600
Lines 44
Message-ID <slrnp7cf2u.d0s.hellsop@nibelheim.ninehells.com> (permalink)
References <qs757d9rh00uro2nmm1kbvsshgq5tq5l9m@4ax.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Trace individual.net lh/yfXU894v++y/hvzGUpgZbw3chvZU1uaaNVlIFlfbM77zkfp
X-Orig-Path nibelheim.ninehells.com!not-for-mail
Cancel-Lock sha1:cAB6zT0BS6tSABjcuAhQpbQWNMg=
User-Agent slrn/0.9.9p1 (OpenBSD)
Xref csiph.com comp.lang.php:17688

Show key headers only | View raw


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

Back to comp.lang.php | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

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

csiph-web