[Solved] mysqli_query() expects parameter 3 to be long

[ad_1] Just call 2 queries separately like this : if($money >= 400) { $query1 = “UPDATE users SET spam = spam + 1, money = money – 400 WHERE user_id=”.$_SESSION[‘user’]; $query2 = “UPDATE users SET score = score + 2500 WHERE user_id=”.$_SESSION[‘user’]; $update1 = mysqli_query($conn,$query1); // call 1st query $update2 = mysqli_query($conn,$query2); // call 2nd … Read more

[Solved] Show more/less on PHP value

[ad_1] Here’s a JS method. I will work on controlling the character count but for now…. window.onload = function() { let rm = document.querySelectorAll(‘.readmore’); rm.forEach(el => { el.classList.add(‘less’); var div = document.createElement(‘div’); div.innerHTML = “<a href=”https://stackoverflow.com/questions/67731164/javascript:void(0);” class=”rmlink” onclick=’toggleRM(this)’>Read more</a>”; el.append(div); }) } function toggleRM(el) { const cl = el.parentNode.parentNode.classList const is_less = cl.contains(‘less’); el.innerHTML = … Read more

[Solved] retrieve data from db using function pdo

[ad_1] Change the function to this: function run_db($sqlcom,$exe){ $conn = new PDO(‘mysql:host=localhost;dbname=dbname’, ‘usr’, ‘pass’); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $conn->prepare($sqlcom); $stmt->execute($exe); return $stmt; } and the call to that function to: try { $stmt = run_db(‘SELECT * FROM posts WHERE status= :published ORDER BY id DESC LIMIT 5’,array(‘:published’ => ‘published’)); while ($result = $stmt->fetch(PDO::FETCH_ASSOC)) { $contents … Read more

[Solved] I want to put text file to table in php

[ad_1] Do something like this. if you need to read a text file then use file_get_contents() function. <?php $fh = file_get_contents(‘text.txt’); $table = json_decode($fh); ?> <table> <thead> <tr> <th>Head 1</th> <th>Head 2</th> </tr> </thead> <tbody> <?php foreach($table as $val){ ?> <tr> <td><?php echo $val->title; ?></td> <td><?php echo $val->Book[0]; ?></td> </tr> <?php } ?> </tbody> </table> … Read more

[Solved] Remove the end of a string with a varying string length using PHP

[ad_1] You can use a regex like this: -\d+x\d+(\.\w+)$ Working demo The code you can use is: $re = “/-\\d+x\\d+(\\.\\w+)$/”; $str = “http://website.dev/2014/05/my-file-name-here-710×557.png”; $subst=”\1″; $result = preg_replace($re, $subst, $str, 1); The idea is to match the resolution -NumbersXNumbers using -\d+x\d+ (that we’ll get rid of it) and then capture the file extension by using (\.\w+)$ … Read more

[Solved] How could I make a calendar? [closed]

[ad_1] javascript date object is pretty handy. You can do something like this to get current dates of the current month: const today = new Date() const date = new Date() date.setDate(1) var calendar=”” for(var i = 0; i < 31; i++) { if(date.getMonth() == today.getMonth()) { calendar += `<div onclick=”openModal()”>${date.getDate()}</div> ` } } This … Read more

[Solved] Get single array value

[ad_1] I Understand What You wants to say use foreach loop insted of print_r() <?php $array = array(“https://example.com/page-1”); foreach($array as $key => $value) { echo $value; } echo “<hr>”; echo $array [0]; ?> Also check Result Here. 5 [ad_2] solved Get single array value

[Solved] Send SMS to mysql contact using php pdo [closed]

[ad_1] As several mentioned in comments above, you need do do this with PHP, as you tagged in your question already. For some projects, I use Plivo which has API documentation for PHP here. I have no connection to this company other than being a (small) client and there are certainly others that might be … Read more

[Solved] lastBuildDate in dynamically generated RSS

[ad_1] The item having the newest PubDate should become the lastBuildTime. [EDIT]: If there is a separate PubDate you are using too for whole feed, then lastBuildTime should be current time because you are building it at current time on-demand :). [EDIT]: 2:: As lastBuildTime is optional and you’re anyways including PubDate for whole feed, … Read more

[Solved] How and where to put Jquery into a fully PHP page?

[ad_1] For Optimizing the performance of a webpage it’s always recommended to put the Javascript file to your footer. So load your script files in your footer file. In wordpress you’ve a footer.php Change <script type=”text/javascript” src=”https://stackoverflow.com/questions/27962150/<?php bloginfo(“template_directory’);?>/javascript/jquery.pajinate.js”></script> TO <script type=”text/javascript” src=”https://stackoverflow.com/questions/27962150/<?php echo echo get_template_directory(); ?>/javascript/jquery.pajinate.js”></script> 7 [ad_2] solved How and where to put Jquery … Read more