logo
down
shadow

Mistake in my pdo if statement


Mistake in my pdo if statement

By : Praveen
Date : November 18 2020, 11:13 AM
I wish did fix the issue. use fetchColumn()
more over i think you should be preparing the statement with :user-id and fav_id
code :
<?php
include '../connect.php';

$fav_id = $_POST['fav_id'];
$user_id = $_POST['user_id'];

$number = $pdo-> prepare('SELECT COUNT(*) FROM favourites WHERE user_id = :user_id AND fav_id = :fav_id ');

$number ->execute(array(':user_id' => $user_id,':fav_id'=>$fav_id));

if ($number ->fetchColumn() == 0) {
$pdo->exec("INSERT INTO `favourites` (`fav_id`, `user_id`) VALUES (" . $fav_id . "," . $user_id . ")");
}
else die();

?>


Share : facebook icon twitter icon
Mistake in a SQL statement

Mistake in a SQL statement


By : Adlet Koshanov
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Take a look at the documentation on pattern matching.
Change
Could any one please point out the mistake in the IF statement

Could any one please point out the mistake in the IF statement


By : fika
Date : March 29 2020, 07:55 AM
hope this fix your issue Judging from the class name and code provided, I assume you are trying to remove all spaces from a string and replacing them with periods?
Your issue lies in the line
code :
if (current != "") {
if (current != ' ') {
Where did I make a mistake in my SQL statement?

Where did I make a mistake in my SQL statement?


By : Loccal D
Date : March 29 2020, 07:55 AM
should help you out Have you tried a UNION? This will allow you to run each query independently and help you narrow down the issue.
code :
select * from db where Money > 100 and currency = 'USD'
UN ION
select * from db where Money2 > 200 AND Currency2 = 'EUR'
Where am i doing a mistake in the for loop statement?

Where am i doing a mistake in the for loop statement?


By : Jacky
Date : March 29 2020, 07:55 AM
Hope that helps You are multiplying everything by 0. After the first loop, prod is 0. Then you use that to multiply by the next value of i. Zero times any number is zero.
You can fix this by iterating in the range [1, num] thus:
Php MySQLI statement skips the 'if' statement to 'else' without any possible mistake in database

Php MySQLI statement skips the 'if' statement to 'else' without any possible mistake in database


By : evisions
Date : March 29 2020, 07:55 AM
hop of those help? Your SELECT and the associated PHP code is completely redundant. All you need is an improved update statement.
Related Posts Related Posts :
  • How to add Smarty templating engine to CodeIgniters 3 framework?
  • Am I maxing out possible data insert
  • Redirect to homepage without changing address bar URL
  • What is the best user-Id Value for a MySql "users" table
  • PHP $_COOKIE is only available in one directory
  • php regular expressions documantation
  • cannot import too large sql file to mysql
  • not getting appilcation/json in content-type in header
  • Only the first data display from my database but other shows but not on a table
  • Is it possible to have a print button link as the content of the mail
  • how to extract full mail address in imap php
  • Alternative to output buffering to put eval'd code into a variable
  • how to run wordpress php snippet mysql update command from ssh and/ultimately cron
  • how to get xml tag by name
  • ModSecurity maximum post limits (PCRE limit errors)
  • Call controller/action in event listener
  • How to improve performance of contacting WebService?
  • PHP nest variable in echoed string that contains a HTML tag in the end
  • Multiple Ajax request for PHP framework
  • Debug Info from Moodle Plugin
  • passing variables through page
  • Passing PHP $result data to Javascript
  • cakePHP File Download was not found or not readable
  • batch waiting until script finishes
  • PHP variables and anchors in URL
  • php eTag generation using php
  • How to check whether the array is an Integer or Not?
  • Is it possible to install Doctrine without PEAR or Composer? If so, how?
  • Call view script of (parent) Abstract controller Zend
  • Curl PHP cannot display amazon
  • Symfony, getters and setters vs magic methods
  • Using 'continue' PHP instruction outside the loop
  • AJAX POST return data not appearing
  • Can I query relations using an INNER JOIN instead of two queries in Eloquent?
  • Looping through dynamic form fields and inserting into database
  • My php code can't select mysql auto_increment value
  • Store Angularjs form data in database using php
  • I want to run my sh file continuously even if I close my Putty connection
  • file_get_contents equivalent for gzipped files
  • Include PHP file with jQuery
  • php curl headers do not return from website?
  • How to find out, if facebook ID is a user, group or page
  • Connect webhost database to android database
  • preg_match get div content with class
  • Upload multiple files in Laravel 4
  • Count array numbers in multidimensional array
  • PHP Date diff with a difference
  • Search Customer by custom field in Netsuite
  • Is it possible to hide/encode/encrypt php source code and let others have the system?
  • list items to be displayed using php code and array
  • check if row exists mysqli
  • PHP errors loading MySQL
  • setup PostgreSQL with Laravel in MAMP
  • PHP - CodeIgniter Notifications
  • Encrypting a password column in a SQL database
  • New to PHP, trying to extract information from another website
  • JavaScript AmChart to Image for Email
  • Is javascript validation enough to keep my forms secure?
  • Regex extract variables from [shortcode]
  • Download a .mp3 link and save it to computer with PHP
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org