Search the Community
Showing results for tags 'php'.
Found 4,040 results
-
i just downloaded this software interspire email marketer to send email campaigns but in the process of sending out email i get to a page where i select the email list i want the email campaign to go to out to. but after i make this selection and click the "Next"button nothig happens. i just click on the button but it doesnt lead to the next page at all. it just remains in the same page. this is very frustrating so i did some research and did a "View Page Source"on mozilla and i found this in the code for that button: <input class="FormButton SubmitButton" type="button" value="Next >>" /> <input class="FormButton CancelButton" type="button" value="Cancel" /> i'm a noob so i looked up the internet and saw that the code here should look more like this below for the button to function like it should: <input class="FormButton SubmitButton" type="submit" value="Next >>" /> <input class="FormButton CancelButton" type="button" value="Cancel" /> my issue however came when i tried to correct this on the webpage code. i downloaded a php editor but it could not locate the page for editing....the page is: http://naudeyfire.atwebpages.com/marketing/admin/index.php?Page=Send but the phpeditor does not locate this page...i do not see it when using ftp ...i only see http://naudeyfire.atwebpages.com/marketing/admin/index.php so my question is two-fold: 1) is it true that changing that code from "button"to "submit" will enable me to proceed to the next page that the button is supposed to link to? 2) how do i find this exact page in order to correct and update it on the server? thank you very much ...
- 1 reply
-
- php
- formbutton
-
(and 1 more)
Tagged with:
-
Great site!, Im trying to understand a bit more pdo.. I have the following: I have a svg and when I click on the map the country name is loaded into a var on the click event by the code below: <script> function fill_contact(evt) //display click event { var country_id = evt.target.id document.getElementById('country_name').firstChild.data = country_id } </script> My php code is as follows: <?php //Define constants define('DB_DRIVER', "mysql"); define('DB_SERVER', "127.0.0.1"); define('DB_DATABASE', "aeea"); define('DB_USER', "root"); define('DB_PASSWORD', "root"); //Database connection try { $dbh = new PDO(DB_DRIVER . ":dbname=" . DB_DATABASE . ";host=" . DB_SERVER, DB_USER, DB_PASSWORD); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch(PDOException $e){ die("Sorry, we could not connect you to this database, please contact the Administrator to sort this out.". $e->getMessage()); } //Get data $query = "SELECT firstname, lastname, email, photo FROM reps WHERE country like ?"; $country = 'country_name'; //Create the statement $stmt = $dbh->prepare($query); $stmt->execute(array($country)); //Use data $row = $stmt->fetch(PDO::FETCH_ASSOC); echo '<pre>', print_r($row), '</pre>'; ?> My Html code is as follows: <div id="IndexPage"> <div id="IndexPage_Left"> <div id="IndexPage_Left_top"> <h3>Country: <span class="label" id="country_name"> </span></h3><!—This works fine--> <p></p> <h4>Regional Representative: <span class="label" id="firstname"> </span></h3></h4><!--get Rep ” firstname, lastname” from database based on country from svg to display--> <p></p> <h4>Photo</h4><!--get Rep “photo” from database based on country from svg to display--> <p></p> <input style='margin-top: 20px;' type="submit" value="Contact me." id='jqxSubmitButton' /><!-- if clicked, it opens a contact form below, the email address is hidden--> </div> <div id="IndexPage_Left_bottom"> <h4>email form here<h4><!-- if email is clicked, it opens a contact form here with “email” address from database --> </div> </div> <div id="IndexPage_Right"> <svg id="map" version="1.1" and rest of svg code. My database has a table called reps. It had dta of representatives in each country in Africa. It has a number of fields ie. rep_id(unique indexed), firstname, lastname, email, postal, city, state, country, contact_no, photo etc. I want to be able to get the fields in the database and display them in the html form on the click events. Ie. The database must also refresh the query every time a click event happens. Guests might click a few countries to look at reps. If they click off the map, it blanks out the details. How do I go about doing this? I’ve heard about XMLHttpRequest but don’t know how to go about doing it. Another question: Once I get the information, how do I display it correctly in the Html? I used <span>, but is it correct? Last question: Once I get the information email address, how do I show a contact form on "conact me" button? and then when guests click on another country, remove the contact form? This is my first website. Please help
-
Hello, I have problem with my pagination script, I tried to add tags to it but selecting second page (next page) when tag is working and filter content of the page, gets me back to second page with content without tag. It should look like this: gallery/page/2/?s=&tag=2 instead: gallery/page/2 I just dont know what to do. Can you help me out? My pagination script: <?php foreach ($this->pagesInRange as $page): ?> <?php if ($page != $this->current): ?> <li><a href="<?php echo $this->url($this->route, array('page' => $page ), true); ?>"><?php echo $page; ?></a></li> <?php else: ?> <li class="active"><a href="#"><?php echo $page; ?></a></li> <?php endif; ?> <?php endforeach; ?>
- 1 reply
-
- pagination
- tag
-
(and 2 more)
Tagged with:
-
Here's my example of using transactions in PDO: I am getting the two errors below when I run my scripts in the browser. PDOException: There is no active transaction in...... Fatal error: Uncaught exception 'PDOException' with message 'There is no active transaction' in ...... here is ny pdo database connection class: <?php class conn { public $host = ''; public $dbname = ''; public $username = ''; public $password = ''; /** * @var object $db_connection The database connection */ private $db_connection = null; public function __construct($host, $dbname, $username, $password) { $this->host = $host; $this->dbname = $dbname; $this->username = $username; $this->password = $password; } public function connected() { try { $this->db_connection = @new PDO('mysql:host='.$this->hos.';dbname='.$this->dbname.';charset=utf8mb4', $this->username, $this->password); return $this->db_connection; } catch (PDOException $e) { echo "Unable to connect to the PDO database: " . $e->getMessage(); } } } And below is the database queries: <?php require('config/conn.php'); $host = 'localhost'; $dbname = 'dbname'; $username = 'username'; $password = 'password'; $db = new conn($host, $dbname, $username, $password); try { //note that calling beginTransaction() turns off auto commit automatically $db->connected()->beginTransaction(); $stmt = $db->connected()->prepare("INSERT INTO category_types (name, cat_id) VALUES (:name, :value)"); $stmt->bindParam(':name', $name); $stmt->bindParam(':value', $value); // insert one row $name = 'one'; $value = 1; $stmt->execute(); // insert another row with different values $name = 'two'; $value = 2; $stmt->execute(); $stmt = $db->connected()->prepare("INSERT INTO category_types2 (name, cat_id) VALUES (:name, :value)"); $stmt->bindParam(':name', $name); $stmt->bindParam(':value', $value); // insert one row $name = 'one'; $value = 1; if($stmt->execute()) //all went well commit! $db->connected()->commit(); } catch (Exception $e) { //Something went wrong rollback! $db->connected()->rollBack(); echo "Failed: " . $e->getMessage(); } What might I be doing wrong? Thanks
-
Ok so on the initial page I have auto incremented hidden input box names so it appears like "cart0Pizzas", "cart1Pizzas", "cart2Pizzas" etc. I am posting these to a process page (user won't see this page - is just so i can post the data and store it into sessions. I want to store the appropiate post data into auto incremented sessions. So when the user clicks on the submit button which is in the same form as for example "cart24Pizzas" it will go into $_SESSION['cart0'] if that one isn't set. If it is, then it can go into $_SESSION['cart1']. If that is set, it will go into $_SESSION['cart2'] and so on. How can I do this? Thanks in advance.
- 10 replies
-
- session
- auto increment
-
(and 1 more)
Tagged with:
-
How can i Add Screen Resolution to PHP Variable and Echo it? i am quite confused on how to do this as getting resolution is done in javascript right? Please help me with this. i have coded my first wordpress theme and this is the only part i am stuck at p.s. I want to save screen height in different variable and screen width in different variable.
-
Hello everyone! I'm having issues with a delete button on a table row, im getting this error: Catchable fatal error: Object of class mysqli could not be converted to string in C:\xampp\htdocs\consultas\newdatapull.php on line 19 I'm not sure whats going on, here's my code: <?php include('header.php'); $servername = "localhost"; $username = "un"; $password = "admin"; $dbname = "emelyconsultas"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); }; if (isset($_POST['delete'])) { $deleteQuery = "DELETE FROM hoteles WHERE id='$_POST[delete]'"; mysqli_query("$conn, $deleteQuery, "); }; $sql = "SELECT id, Full_Name, Email_Address, Telephone_Number, pais, ciudad, nombre_hotel, fecha_in, Fecha_out, adultos, ninos, mensaje FROM hoteles"; $result = $conn->query($sql); if ($result->num_rows > 0) { echo "<div class='container-fluid'> <div class='col-md-12'> <div id='datatable'class='table-responsive well'> <h1 class='text-center'>Entradas</h1> <table id='table' class='table'> <tr> <th>ID</th> <th>Nombre</th> <th>Correo Electronico</th> <th>Numero Telefonico</th> <th>Pais Destinado</th> <th>Ciudad Destinada</th> <th>Hotel</th> <th>Check In</th> <th>Check Out</th> <th>Adultos</th> <th>Niños</th> <th>Mensaje</th> </tr>"; // output data of each row while($row = $result->fetch_assoc()) { echo "<form action=newdatapull.php method=post>"; echo "<tr>"; echo "<td>" .$row['id'] . " </td>"; echo "<td>" .$row['Full_Name'] . " </td>"; echo "<td>" .$row['Email_Address'] . " </td>"; echo "<td>" .$row['Telephone_Number'] . " </td>"; echo "<td>" .$row['pais'] . " </td>"; echo "<td>" .$row['ciudad'] . " </td>"; echo "<td>" .$row['nombre_hotel'] . " </td>"; echo "<td>" .$row['fecha_in'] . " </td>"; echo "<td>" .$row['Fecha_out'] . " </td>"; echo "<td>" .$row['adultos'] . " </td>"; echo "<td>" .$row['ninos'] . " </td>"; echo "<td>" .$row['mensaje'] . " </td>"; echo "<td>" .$row['id'] . " </td>"; echo "<td>" ."<input class=input-group type=submit name=delete value=Borrar>" . "</td>"; "</form>"; echo "</tr></table></div></div></div>"; } } else { echo "0 results"; } $conn->close(); include('footer.php'); ?> thanks in advance to anyone that can help, Error comes up once I click the Delete button on the row...
-
Hi all, For example, many vendor websites allow users to refine a search e.g. Lowest Price First. I need some help to implement this into my website. I have tired to do this using a submit button but it just refreshes the page, and the data that the user has used to search for the produce in the first place.
-
Hi I’m looking for a standalone PHP OOP framework or code that follows best practices using - PDO prepared statements - Singleton Design Pattern Not looking for a massive library, something short and sweat straight to the point Any comments, feedback would be appreciated
-
I'm making my own CMS for my company so going through making the pages for the back end. What I want to do that I'm stuck on is -------------- I want to allow the user to specify how many input text fields they want shown on the page. I'm thinking that they could write a number then click submit, send the data to the same page (PHP self or action blank) and then the required amount of input fields would be echoed out. Echoing out is easy, I want to know how to find out how many fields are required, and then process it. Thanks in advance.
-
After uploading my PHP project to a live server, I get this error message when accessing some pages. But when running on localhost, I do not get this error and every script is working properly. I have checked white spaces, PHP opening closing tags, and Encoding without BOM. But I still couldn't figure this out. This is my header.inc.html page: <?php # -- header.html // This page begins the HTML header for the site. // Check for a $page_title value: if (!isset($page_title)) $page_title = 'Computer store | Control Panel'; ?><!DOCTYPE html> <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--> <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]--> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title><?php echo $page_title; ?></title> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" type="image/ico" href="favicon.ico"/> <link rel="apple-touch-icon" sizes="152x152" href="apple-touch-icon-precomposed.png" /> <link rel="stylesheet" href="css/styles.css"> <script src="js/vendor/modernizr.min.js"></script> </head> <body> <!--[if lt IE 7]> <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p> <![endif]--> <!-- End of header. -->
-
Hi there, I'm learning PHP and working on building an ecommerce site using a MVC. I can display all six categories from the database on the index page however I only want to show four of these, as the links at the top will be the six categories. By using the next() method I can display all six categories: <?php while ($categories->next()) { ?> <section class="product"> <a href="products/<?= $categories->getURL() ?>"><h3 class="upper"><?= $categories->getName() ?></h3></a> <br/> <img src="<?= IMAGE_URL . $categories->getImage() ?>" style="width:80%; height:auto;" alt="Menu Tab"/> <h3 class="under"><a href="products/<?= $categories->getURL() ?>">SHOP NOW >></a></h3> </section> <?php } } } ?> I am wondering how to only extract certain products (each has a catID in the database). I thought the switch statement might be the answer and here was my attempt that did not work. I guess I am still not saying which catID to get but unsure how to fix this. Or is there another way not using switch? while ($categories->next()) { switch ($categories->getID()) { case 1: case 2: case 3: case 4: ?> <section class="product"> <a href="products/<?= $categories->getURL()?>"><h3 class="upper"><?=$categories->getName() ?></h3></a> <br/> <img src="<?=IMAGE_URL. $categories->getImage()?>" style="width:80%; height:auto;" alt="Menu Tab"/> <h3 class="under"><a href="products/<?= $categories->getURL()?>">SHOP NOW >></a></h3> </section> <?php break; default: return ""; } } } } ?> Any help would be greatly appreciated! Cheers
-
Hello guys. I have a problem with signup form record in database. My code works good but only firstname input doesnt send it to database. Other all information shown up in database. Do you have any idea why it is not working? <?php // index.php session_start(); require_once 'functions.php'; $userfirstname = $lastname = $email = $remember = $error = $username = $pass = $password1 = $password2 = $user = $birthday = $bdd = $bdm = $bdy = ""; $imgavatar = 'img/default_user_avatar.png'; $userstr = '(Guest)'; if (isset($_SESSION['user'])) { $user = $_SESSION['user']; $loggedin = TRUE; $userstr = " ($user)"; } else $loggedin = FALSE; if ($loggedin){ //redirect for profile page } if(isset($_POST['username'])&&($_POST['first']) && ($_POST['lastname']) && ($_POST['email'])){ $username = sanitizeString($_POST['username']); $password1 = sanitizeString($_POST['p']); $password2 = sanitizeString($_POST['p2']); $email = sanitizeString($_POST['email']); $userfirstname = sanitizeString($_POST['first']); $lastname = sanitizeString($_POST['lastname']); $bdd = sanitizeString($_POST['day']); $bdm = sanitizeString($_POST['month']); $bdy = sanitizeString($_POST['year']); $birthday = $bdd." / ".$bdm." / ".$bdy; if ( ($username == "") || ($email =="") || ($password1 =="") || ($password2 =="") || ($userfirstname = "") || ($lastname == "")) { $error = "You didn't give us enough information for Signup"; } else { $result = queryMySQL("SELECT * FROM Members WHERE username='$username'"); if($result->num_rows) { $error ="This Username is already exists"; } else { queryMysql("INSERT INTO Members VALUES( '$userfirstname','$lastname','$email','$username','$password1','$birthday')"); die("<h4>Account created</h4>Please Log in. Your first name is $userfirstname<br><br>"); } } } echo <<<_END <DOCTYPE html> <html> <head> <title>World. Your New World</title> <link rel='stylesheet' href='styles.css' type='text/css'> <script type="text/javascript" src="javascript/javascript.js"></script> </head> <body class='home'> <div class='loginform'> <img id='imgavatar' src='$imgavatar'> <form method='post' action='index.php'> <input class = 'loginput' type='text' maxlength='16' name='user' value='$user' placeholder='Username'> <input class = 'loginput' type='password' maxlength='16' name='pass' value='$pass' placeholder='Password'> <h6 id='rememberme'><input type="checkbox" value="None" name="check" checked='checked' />Remember Me</h6> <span>$error<br></span> <input type='submit' value='Login'> </form> </div> <div class='signupform'> <h1 id='signhead'>Join Us!</h1> <p id='signhead'>It will be free and it will always be free!<br> Creat your own personal tree</p><br><br><br> <form method='POST' action='index.php'> <input class= 'loginput' type='text' maxlength='16' name='first' value='$userfirstname' placeholder='Name'> <input class= 'loginput' type='text' maxlength='16' name='lastname' value='$lastname' placeholder='Last Name'><br> <input class= 'loginput' type='email' maxlength='32'name='email' value='$email' placeholder='E-mail'> <input class= 'loginput' type='text' maxlength='16' name='username' value='$username' placeholder='Username' onBlur='checkUser(this)'><br> <input class= 'loginput' type='Password' maxlength='16' name='p' value='$password1' placeholder='Password'> <input class= 'loginput' type='Password' maxlength='16' name='p2' value='$password2' placeholder='Repeat Password'><br> <select name="month" onchange="call()" value='$bdm'> <option value="0">-Month-</option> <option value="1">January</option> <option value="2">February</option> <option value="3">March</option> <option value="4">April</option> <option value="5">May</option> <option value="6">Jun</option> <option value="7">July</option> <option value="8">August</option> <option value="9">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> <select name="day" value='$bdd'> <option value="">-Day-</option> </select> <select name="year" onchange="call()" value='$bdy'> <option value="">-Year-</option> </select> $userfirstname $lastname <input type='submit' value='Sign Up'> </form> </div> </body> </html> _END; ?>
-
Hi everyone, i am marking a number of php questionnaire forms on my webpage and they connect up to a Mysql database, so far so good. However, the part i am having trouble with is... i need certain questionnaires to only be released for fixed periods of time (for example 1/2 weeks). Would anyone be able to help me out and give me some idea of how i would go about this? Thanks
- 3 replies
-
- questionnaire
- php
-
(and 2 more)
Tagged with:
-
Good Afternoon Ladies & Gentlemen, I am interested in learning php programming. I do not have any programming background in any other programming languages be it computer programming (C, C++, C#, Perl, Java, etc.) or web programming ( Server Side: Php, Perl Cgi, Python, Ruby on Rails; Clientside: Javascript, Xml, Xhtml, CSS, etc.). I only know basic Html and currently use a bot programmign tool "Ubotstudio" but that's all. Can you be kind enough to recommend me a paper book where I can learn php without getting confused ? It must teach the latest stable version. Q1. Which php version is stable and which version is installed on webhosts the most ? 5.5.8 ? If so, where can I get a paper book to learn it or where can I learn it online from some free tutorial ? I actually prefer to learn it from a paper book as I am not always connected to the internet. I am using internet cafe to send this message/post. I was just checking Amazon now but a lot of books meant for the beginners have got bad reviews/ratings from customers and that has left me confused and worried. The book must be for total beginners and not for intermediate or advanced programmers. It must not leave out any basics but teach it. Must teach the full default library (all the "Commands", "Functions", "Sub functions", "Syntaxes" or whatever that exists in the language from top to bottom and not miss out anything. Must teach the full grammer of the language and not leave-out anything). You may recommend any free tutorial websites too but like I said I actually prefer to learn it from a paper book as I am not always connected to the internet. I am using internet cafe to send this message/post. Q2. What is Php frame work ? Reusable code blocks meant for a specific task such as deal with database, etc. ? If so, I'm not interested in getting into heaviuly learning one framework and not learn the full language. No good being just an eye specialist or a bone specialist (one field only). Might aswell be a general doctor (GP) that knows a little bit of all fields. I think you know what I mean. Let's learn the basics of the general stuffs first (the core of the language), I can them later-on move-on to other fields such as database, etc. And so, the book must not concentrate on one field only such as to build CMS or Social Network Account Logins or Forums or Database (MySql) because then I'd only learn one aspect of php and not the basics. In short, I want to learn the basics of the language and get a strong background in it. I prefer to build php scripts for Unix/Linux, Apache Webserver using MySql database. Book must teach step by step. Must teach A, B, C then 1, 2, 3 and 1+1=2, 2*2=4, 5-2=3, 25/5=5 and so on before jumping into the algebra and geometry (if you understand what I mean when we speak in terms of learning basic English and Maths). I don't want to program in one version and then see my webhost uses another version. Currently, my webhost is Hostgator. If I have come to the wrong department/category then kindly forward this message/post to whoever can help. I await every php lover's reply. Q3. Where did you learn php ? WHich website you used and which paper book ? Were they good or not so good or bad ? PS - What do you think about this book: http://www.amazon.co.uk/PHP-Programming-Ultimate-Course-Beginners-ebook/dp/B00PSNRK16/ref=sr_1_12?s=books&ie=UTF8&qid=1429028734&sr=1-12&keywords=php+5 It seems it's not a paper version. Do you reckon it will do the job or not ? PPS - if you can't recommend any paper books then do you recommend any website where I can go and printout the tutorials ? The website must qualify all that I said earlier about the book. Anyway, I was expecting the Php Board to provide basic teachings of the language on their website but I'm disappointed to see they don't! Thank You Mr. Ali
- 2 replies
-
- php
- programming
-
(and 2 more)
Tagged with:
-
I am trying to change the class of a button if a conditon is not met ( if(strlen($username) < 5) ) this is my code : <?php $buttonClass = 'btn btn-primary'; ?> <?php if(isset($_POST['name']) && $_POST['name'] != ""){ $username = preg_replace('#[^a-z0-9]#i', '', $_POST['name']); $quer = "SELECT * FROM users WHERE username = '$username'"; $resu = mysqli_query($dbc,$quer); $check = mysqli_num_rows($resu); if(strlen($username) < 5){ echo '<span class = "glyphicon glyphicon-remove" style = "color:red"> More then 4 caracters </span>'; $buttonClass = 'btn btn-primary disabled'; exit(); } elseif(is_numeric($username[0])){ echo '<span class = "glyphicon glyphicon-remove" style = "color:red"> First character mst be a letter </span>'; $buttonClass = 'btn btn-primary disabled'; exit(); } elseif($check < 1){ echo '<span class = "glyphicon glyphicon-ok" style = "color:green"> ' . $username . ' is available</span>'; }else{ echo '<span class = "glyphicon glyphicon-remove" style = "color:red"> This username is already taken </span>'; $buttonClass = 'btn btn-primary disabled'; exit(); } } ?> <script type="text/javascript" language = "javascript"> function checkUsername () { var status = document.getElementById("usernamestatus"); var u = document.getElementById("username").value; if(u != "") { status.innerHTML = 'Se verifica...'; var hr = new XMLHttpRequest(); hr.open("POST","register.php",true); hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); hr.onreadystatechange = function(){ if(hr.readyState == 4 && hr.status == 200){ status.innerHTML = hr.responseText; } } var v = "name="+u; hr.send(v); } } </script> AND this is my html(under the php and the script) <div class="form-group"> <label for="username" class="col-lg-2 control-label">Username:</label> <div class="col-lg-10"> <input type="text" name = "username" class="form-control" id="username" onkeyup="checkUsername()"> <br><div class = "userspan"> <span style = "font-size:15px"id = "usernamestatus"></span> </div> </div> </div> <button type="reset" class="btn btn-default">Cancel</button> <button type="submit" class="<?php echo $buttonClass ?>" id = "submit" >Submit</button> Now i know there is something to do with the exit() function but if i don't put it then the html apears on the page twice,how can i stop that from happening ? Please can someone help ?
-
I'm trying to get a users email so it will update them when they purchased premium, I'm using Stripe as my payment system. The only way I can get it to work, is if I insert their email/id into my php page. I'm wanting the page to get the users email on it's on. $_SESSION['user_id'] = 9; $stripe = array( "secret_key" => "sk_test_rDYOBYxCErhrgGCeWQJhR4mQ", "publishable_key" => "pk_test_3mIuE3OsajKO4cnFppcDDISu" ); \Stripe\Stripe::setApiKey($stripe['secret_key']); $db = new PDO('mysql:host=127.0.0.1;dbname=blog', 'root', ''); $userQuery = $db->prepare(" SELECT id, username, email, premium FROM users WHERE id = :user_id "); $userQuery->execute(['user_id' => $_SESSION['user_id']]); $users = $userQuery->fetchObject(); I'm using ID's right now, I have to enter them on my own. The website isn't live, just testing. I can get the users email with Stripe on my checkout page by putting echo $users->email & the email shows up on the purchase screen, where normally they would have to type it. I'm not sure how to get it on purchase so it will update the user in the DB though.
-
Is there a way to get the count of rows like this? $count = somefunctionthatreturnscount(mysqli_query($mysqli, "SELECT COUNT(*) FROM table")); Instead of... $count = mysqli_num_rows(mysqli_query($mysqli, "SELECT id FROM table")); //or even... $count = mysqli_fetch_array(mysqli_query($mysqli, "SELECT COUNT(*) as count FROM table")); Ultimately, I want the method that will get the count the quickest and if can be done similarly to the first code and still have good performance. Thanks in advance! Update: Reported post as duplicate. Need moderate to delete duplicates as that option is not appearing for me.
-
I have the following code, my bad if it is not in correct format... still learning. <?php $string = file_get_contents('/path/to/file'); $found = 'found'; if($string == $found){ echo "string match"; } else { echo "string does not match found"; } echo "<br>"; echo "value of string: $string"; echo "<br>"; echo "value of found: $found"; ?> The output of that says: "string does not match found". and the value for $string and $found is the same. If the value of $string and $found are not the same it still says:"string does not match found". Am I missing something or am I going nuts... Please let me know what is wrong with my code.Thanks in advance
-
Hi Guys, Can someone please help me. I have following PHP code that works fine. The only issue I am facing is, if there is a payment thats not sucessfull I just get a blank screen, and do not receive error on the screen. However the error is dispalyed in execption, I just can catch it. CODE: <?PHP require './lib/Stripe.php'; $ccnum=$_GET['ccNum']; $ccmon=$_GET['ccExpMo']; $ccyr=$_GET['ccExpYr']; $amount=$_GET['amt']; $jobid=$_GET['JobId']; $multiply=100; $amountcents=$amount*$multiply; $cvc=172; $description='something'; if(isset($_POST)) { Stripe::setApiKey("stripe_key_here"); $payment = Stripe_Charge::create(array( 'amount' => $amountcents, 'currency' => 'gbp', 'card' => array( 'number'=> $ccnum, 'exp_month' => $ccmon, 'exp_year'=> $ccyr, 'name'=> 'some name', 'cvc'=> $cvc), 'description' => $description)); } print_r($payment); ?> Following is the error (or any other error) which I cant seem to catch as an execption. error: message: "Your card has insufficient funds." type: "card_error" code: "card_declined" charge: ch_12asdasweAAFdgooXDUd2tvKJgW Thanks a lot again for any advise. Regards,
-
hi guys i have been trying to limit users in my registration page to no avail the code exceeds the limit user of users in the db pliz help here is my code <?php include("connect.php"); // first we write the html layout code //code to check if the user pressed the button if($_SERVER['REQUEST_METHOD'] == 'POST') { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string(md5($_POST['password'])); // retrieving the input from the user, also securing for SQL injection and encrypting the password //to md5 //now its time to check if the user input works(fields not empty) if(empty($username)) { echo ("You have to fill in a username!"); } else { if(empty($password)) { echo("you have to fill in a password!"); } else { $query= mysql_query("SELECT * FROM users WHERE username = '$username' && password='$password'"); $rowcount = mysql_num_rows($query); if ($rowcount > 4){ die("Sorry, no more users can sign up"); }else{ //if $rows = 0 username is not taken and user can be saved in the database. $user_input = mysql_query("INSERT INTO users (username,password) VALUES ('$username', '$password')"); echo ("Successful registration!"); // last thing to do is include the config.php file where the connection is to the database } } } } ?>
-
i just created a new website for my local school i want to create a databse which will contain roll number ,marksof variosu subjects & name of students i created the database but now when i am trying to create a php script to enter students details i am having prouble in connection access denied for user 'abc'@'localhost' todatabse 'abc_db' what am i doing wrong ?? i think its because of user dont have proper privileges, how to give user privileges ?
-
I am trying to create a page which displays user profile. I have created two classes one is dbconnect(which is database class) and the other is Profile class(which shows profile). Now I am trying to pass object of dbconnect class as arguments for the constructor of profile class. I am getting error undefined variable database_profile Here is my code of profile php class Profile{ private $user_id; private $profile_array; private $database_profile; public function __construct($user,dbconnect $database_link){ $this->user_id = $user; $this->database_profile = $database_link; } public function make_array(){ $sql = "SELECT * FROM users WHERE id = '$this->user_id'"; $result = $database_profile->run_query($sql); $profile_array = mysqli_fetch_array($result, MYSQLI_ASSOC); echo $profile_array['first_name']; } public function show_profileinfo(){ } public function profilepic(){ return $profile_array['avatar']; } } //Loads database $database_connect = new dbconnect("localhost","root",""); $database_connect->select_database("selftest"); //Loads Profile $profile = new Profile($_SESSION['userid'],$database_connect); $profile->make_array(); Here is my code of dbconnect class class dbconnect{ public $database_selected; private $data_select; public function __Construct($host,$user,$pass){ $this->database_selected = mysqli_connect($host,$user,$pass); if (!$this->database_selected) echo "Connection to database failed"; else echo "Connection to database successful!"; } public function select_database($database_name){ $this->data_select = mysqli_select_db($this->database_selected, $database_name); if(!$this->data_select) echo "Connection to table failed"; else echo "Connection to table successful!"; } public function close_connection(){ $close = mysqli_close($this->database_selected); if ($close) echo "<p>Connection successfully closed</p>"; else echo "<p>Failure in closing connection</p>"; } //Returns aither true or false public function run_query($sql){ return $query_success = mysqli_query($this->database_selected,$sql); } }
-
I's trying to transform data from mysql into something like $books below but it doenst seem to be working $books = array( "phil" => array("my girl" => 2.5, "the god delusion" => 3.5, "tweak" => 3, "the shack" => 4, "the birds in my life" => 2.5, "new moon" => 3.5) ) this is how I tried doing: $sql = "SELECT * from rating where user_id=11 limit 5"; $db_result = mysql_db_query($dbname,$sql) or trigger_error(mysql_error()); $num_rows = mysql_num_rows($db_result) or trigger_error(mysql_error()); while ($row = mysql_fetch_array($db_result)) { $one = $row['bookId']; $two = $row['user_id']; $three = $row['rating']; $ArraY= array( $two => array($one=>$three) ); print_r($ArraY); } but this is what i get : Array ( [11] => Array ( [123715] => 5 ) ) Array ( [11] => Array ( [140329] => 5 ) ) Array ( [11] => Array ( [3083854] => 4 ) ) Array ( [11] => Array ( [871236761] => 1 ) ) Array ( [11] => Array ( [451179757] => 1 ) ) Array ( [11] => Array ( [451403886] => 3 ) ) Array ( [24] => Array ( [044661095X] => 4 ) ) Array ( [24] => Array ( [014010268X] => 1 ) ) Array ( [24] => Array ( [812576063] => 5 ) ) Array ( [24] => Array ( [038076654X] => 1 ) ) instead of something like: Array ( [phil] => Array ( [my girl] => 2.5 [the god delusion] => 3.5 [tweak] => 3 [the shack] => 4 [the birds in my life] => 2.5 [new moon] => 3.5 ) [sameer] => Array ( [the last lecture] => 2.5 [the god delusion] => 3.5 [the noble wilds] => 3 [the shack] => 3.5 [the birds in my life] => 2.5 [new moon] => 1 ) [john] => Array ( [a thousand splendid suns] => 5 [the secret] => 3.5 [tweak] => 1 ) [peter] => Array ( [chaos] => 5 => 3.5 ) [jill] => Array ( [the last lecture] => 1.5 [the secret] => 2.5 [the noble wilds] => 4 [the host: a novel] => 3.5 [the world without end] => 2.5 [new moon] => 3.5 ) [bruce] => Array ( [the last lecture] => 3 [the hollow] => 1.5 [the noble wilds] => 3 [the shack] => 3.5 [the appeal] => 2 [new moon] => 3 ) [tom] => Array ( [chaos] => 2.5 ) ) Any help with how i can transform that will be much appreciated THANKS
-
Hello, I have created two tables "category" and "subcategory". So what i need to do is that i have organized two combobox and one will retrieve values from category table and populate the data. However, i need to fill the other combobox when one selected from the category combobox and populate all the values from subcategory table. I really thank you all for helping me out. Looking for great answer. Thank you in advance. Fekade