PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Sep 26, 2017 1:16 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Mon Sep 11, 2017 3:39 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4335
Location: United Kingdom
This script is not running anything. It' snot doing any inserts, and not throwing up any errors.
How do I identify why is it not inserting anything?
If the db name or fields were incorrect, it would stop and through an error. It isn't.

Syntax: [ Download ] [ Hide ]
$today = (date('Y-m-d'));

// random code to be added to email for clarification
$random = (rand()%99999999);

                        $query = $pdo->query("INSERT INTO admin (firstname, lastname, email, created, password, address1, address2, town, county, postcode, `type`, telephone, drivinglicense, shift, status) VALUES (:firstname, :lastname, :email, :today, :password, :address1, :address2, :town, :county, :postcode, :user, :telephone, :drivinglicense, :shift, :random)");
                       
      $result = $pdo->prepare($query);
     
      $result->execute(array(':firstname' => $firstname, ':lastname' => $lastname, ':email' => $email, ':today' => $today, ':password' => $password, ':address1' => $address1, ':address2' => $address2, ':town' => $town, ':county' => $county, ':postcode' => $postcode, ':user' => $user, ':telephone' => $telephone, ':drivinglicense' => $drivinglicense, ':shift' => $shift, ':random' => $random));

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Mon Sep 11, 2017 12:30 pm 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6556
Location: WA, USA
What $result successfully prepared? What does ->execute() return? What do you have the PDO error reporting setting as?


Top
 Profile  
 
PostPosted: Tue Sep 12, 2017 5:26 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6353
Location: Montreal, Canada
Hang on. PDO::query executes the query. You're then passing the results of that to PDO::prepare. Skip the first step and just pass the query string to PDO::prepare.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Tue Sep 12, 2017 5:39 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4335
Location: United Kingdom
Yes I just noticed that too. I've got two of them. It's sorted now thanks.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group