Jump to content

Search the Community

Showing results for tags 'pdo'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hi all, I am working on a search script which searches article titles from the table. i have worked out the function, but have not been able to add an error message if the results are zero. my class file has this following function public function search($table){ $search=$_GET['search']; if ($this->databaseConnection()) { $sql="SELECT * FROM $table WHERE title LIKE '%$search%'"; $q = $this->db_connection->query($sql) or die("failed!"); while($r = $q->fetch(PDO::FETCH_ASSOC)){ $data[]=$r; } return $data; } } my results page has the following code <?php foreach($crud->search("articles") as $value){ extract($value); echo <<<show <p>" <a href="view.php?article_id=$article_id">$title</a> "</p> <br> show; } ?> would be highly obliged if anyone can help me out. apologies if this is a stupid question, but i am pretty much an amateur still. regards, Nayan
  2. Hello All, Have a GoDaddy MySQL PHP:PDO hosting questions. Using a database class to make script queries. Unfortunately, I'm required to use GoDaddy Windows hosting. However, I'm a Linux kind of guy. Here's the issue. The viewer script includes database credentials defined as constants, in a file outside the root directory. Typically, these constants are available to all sub processes including class objects. Everything works as expected on development server. The error message I get with version using constants: L226: projectGallery_class datapull Caught Exception --- invalid data source name with host string userDBName.db.6482519.hostedresource.com;dbname=userDBName However when I deploy to GoDaddy's production server, the constants are defined - but empty. Here is the example code. /* works on Linux */ class datapull { var $host; // not assigned here var $userName; // not assigned here var $userPass; // not assigned here protected function conn() { try { $DB = new PDO(DB_HOST,DB_UNAME,DB_PASS); $DB->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); return $DB; } catch( Exception $e ) { $mes = "L226: datapull::conn() Caught Exception --- "; $mes .= $e->getMessage(); error_log($mes); } } public function dbquery($qqueue) { $DB = (!isset($DB)) ? $this->conn() : $DB; /* some query stuff here */ return $result } The modified class for GoDaddy Windows class datapull { var $host = “mysql:host=userDBName.db.1234567.hostedresource.com;dbname=userDBName”; var $userName = “userDBName”; //godaddy user and database naming convention var $userPass = “userPWDString”; //user password protected function conn() { try { $DB = new PDO($this->host,$this->userName,$this->userPass); $DB->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); return $DB; } catch( Exception $e ) { $mes = "L226: datapull::conn() Caught Exception --- "; $mes .= $e->getMessage(); error_log($mes); } } public function dbquery($qqueue) { $DB = (!isset($DB)) ? $this->conn() : $DB; /* some query stuff here */ return $result }
  3. I am having a bit of issue. I have a simple query that loops to find each record, like this. // select query here if(count($result) > 0) { foreach($result as $row) { $userid = $row['user_id']; $_SESSION['userid'] = $userid; } } else { // error here } I want to use the "$userid" on a different page; so I created a session for it. When ever I use that session on another page, it gives me only the last record's user id and not the first one. How can I fix this?
  4. This should all be working but I think I might be overlooking something. Problem 1. I am using ajax to process a form. I don't think the problem is with ajax(works with other queries), but rather with php. Here is my simple query. $stmt = $db->prepare("SELECT * FROM records WHERE request_by = :request_by, request_to = :request_to AND session = :session"); $stmt->bindParam(':request_by', $byUserid); $stmt->bindParam(':request_to', $toUserid); $stmt->bindValue(':session', 1); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); if(count($result) > 0) { $success = 'This was successful.'; } else { $error = 'There was a problem.'; } This above query gives me this error. Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' request_to = '7' AND session = '1'' at line 1 Problem 2. Say the main page is "index.php" with submit form and I am using ajax via url: process.php. Well on "index.php" page, I have foreach loop that gets me a "$toUserid" for each record. I would like to use that "$toUserid" in "process.php" page. I tried setting it as a session but still it won't give me that exact userid. It'll give me the same userid as the user I am currently logged in. What exactly I am doing wrong and how I can i fix it?
  5. Hi, I'm quite new to OOP PHP and i'm trying to make a dynamic insert function , i've followed an example on Stackoverflow to do so since its my first try at making something dynamic.http://stackoverflow.com/a/13333344/3559635 It works but im still quite confused about the two foreach loops , and if possible could someone explain that part to me please and or is there an easier more clean way to do this for a new guy like me? Im sending my POST values from the index.php <?php include("Database.php"); $db = new Database(); var_dump($db); $table = "users"; $whitelist = array('username', 'password'); $data = array_intersect_key($_POST, array_flip($whitelist)); if(isset($_POST['username']) AND ($_POST['password'])) { $db->postTesting($data, $table); } else { echo "Please fill in everything!"; } Database.php <?php class Database { private $connection; private $typedb = "mysql"; private $host = "127.0.0.1"; private $dbname = "oopphp"; private $username = "root"; private $password = ""; public function __construct() { try{ $this->connection = new PDO($this->typedb. ":host=".$this->host. ";dbname=".$this->dbname, $this->username, $this->password); $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); return $this->connection; } catch(PDOException $e) { throw new Exception("Connection failed: ".$e->getMessage()); } } public function postTesting($data, $table) { try{ //var_dump($table, $data); $columns = ""; $holders = ""; foreach ($data as $column => $value) { //var_dump($column); //var_dump($value); $columns .= ($columns == "") ? "" : ", "; $columns .= $column; $holders .= ($holders == "") ? "" : ", "; $holders .= ":$column"; //var_dump($columns); //var_dump($holders); } $sql = "INSERT INTO $table ($columns) VALUES ($holders)"; //return $sql; $stmt = $this->connection->prepare($sql); //var_dump($stmt); foreach ($data as $placeholder => $value) { $stmt->bindValue(":$placeholder", $value); //var_dump($stmt); //var_dump($placeholder); //var_dump($value); } //var_dump($sql); //var_dump($stmt); $stmt->execute(); } catch(PDOException $rError) { throw new Exception("Registering Failed: ".$rError->getMessage()); } } } Im seriously confused about this part. foreach ($data as $column => $value) { //var_dump($column); //var_dump($value); $columns .= ($columns == "") ? "" : ", "; $columns .= $column; $holders .= ($holders == "") ? "" : ", "; $holders .= ":$column"; //var_dump($columns); //var_dump($holders); } Thanks in advance for the help
  6. I'm not sure where to exactly begin with this query, but here's the objectives: Column A values: 3, 5, 7, 9, 21 Column B value: 2 Column User: $id Perform an if on each separate column A while ran in a batch process to speed up the query
  7. $news='news'; $sql_news = "INSERT INTO `rise`.`news` ( `user` , `message` ) VALUES ( :id, :news );"; $q_news = $conn->prepare($sql_news); $q_news -> execute(array(':id'=>$id, ':news'=>$news)); print_r($q_news); echo $q_news->rowCount(); Why does it echo 1 instead of 2 when everything else on the page is turned off for processing, and it's the last thing on the page? Why do 2 inserts happen?
  8. so my situation is something like this , i'm trying to fetch user details based on `id` that isset is getting, but some how the `variable that contains the $_GET value doesn't work` in query but when i put an static value to pdo query then it works and show the result. i have checked by doing `var_dump` of variable `$user` before query and it shows the correct value but not working in query. Below is the code i'm working with: public function profile_view($user_id = null) { $user = $user_id; $stmt = $this->_db->prepare('SELECT memberID,username,email,profile_pic,active FROM members WHERE memberID = :user_id AND active="YES"'); $stmt->execute(array(':user_id'=>$user)); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $user_det = (object) array('username'=> $row['username'],'email'=>$row['email'],'profile_pic'=>$row['profile_pic'],'id'=> $row['memberID'],'active'=>$row['active']); return $user_det; } } this is how function is being called (profile_view function is child of User class so $user is class User) : $view_profile = $user->profile_view($_GET['u']); the above code returns null but when i put static value : `5` at the place of `$user` in `$stmt->execute` it returns the whole user's details which is what i need , but its not working with variable which is confusing me alot , thanks in advanced for help.
  9. Hi guys. why is my function error: undefined varable pdo? Thanks function referralCount($uid,$reflvl) { $stmt= $pdo->query("SELECT * FROM scraffiliateusr WHERE usrinvby='$uid'"); $nusrref1 = $stmt->rowCount(); //$arrusrref1 = $stmt->fetch(PDO::FETCH_LAZY); $reflvl1=$nusrref1; $ttlreflvl2="0"; $ttlreflvl3="0"; for ($i=0; $i<$nusrref1; $i++) { $arrusrref1 = $stmt->fetch(PDO::FETCH_LAZY); $stmt= $pdo->query("SELECT * FROM scraffiliateusr WHERE usrinvby='$arrusrref1[0]'"); $nusrref2 = $stmt->rowCount(); //$arrusrref2 = $stmt->fetch(PDO::FETCH_LAZY); $ttlreflvl2=$ttlreflvl2+$nusrref2; for ($j=0; $j<$nusrref2; $j++) { $arrusrref2 = $stmt->fetch(PDO::FETCH_LAZY); $stmt= $pdo->query("SELECT * FROM scraffiliateusr WHERE usrinvby='$arrusrref2[0]'"); $nusrref3 = $stmt->rowCount(); //$arrusrref3 = $stmt->fetch(PDO::FETCH_LAZY); $ttlreflvl3=$ttlreflvl3+$nusrref3; } } $reflvl2=$ttlreflvl2; $reflvl3=$ttlreflvl3; if($reflvl=='1') { return($reflvl1); } elseif($reflvl=='2') { return($reflvl2); } elseif($reflvl=='3') { return($reflvl3); } }
  10. Is it possible to do this with one query? Tried with union and join but no luck. <?php $query = 'SELECT cashReward, pointsReward FROM pts WHERE signupsAvailable > 0 AND status = "active" AND id = :id'; $select = $db->prepare($query); $select->bindParam(':id', $id, PDO::PARAM_INT); $select->execute(); $rowCount = $select->rowCount(); $queryC = 'SELECT COUNT(id) FROM ignored_pts WHERE user = :username AND ptsId = :id'; $selectC = $db->prepare($queryC); $selectC->bindParam(':username', $userInfo['username'], PDO::PARAM_INT); $selectC->bindParam(':id', $id, PDO::PARAM_INT); $selectC->execute(); $count = $selectC->fetch(PDO::FETCH_COLUMN); if($rowCount == 1){// PTS // $row = $select->fetch(PDO::FETCH_ASSOC); if($count == 0){// IGNORED PTS // // ...................... // // INSERT INTO ignored_pts TABLE $row['cashReward'], $row['pointsReward']// // ...................... // print 'PTS IGNORED'; }else{ print 'You have already ignored this PTS!'; } }else{ print 'An invalid PTS was provided!'; } $db = NULL; ?>
  11. I have a pdo prepared statement that fetches records from mysql database. The records show up on the page. However if there are no records on a page, I get this error message. "QLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-10' at line 4" Here is my statement $getCategoryId = $_GET['id']; $limit = 10; $offset = ($page - 1) * $limit; $statement = $db->prepare("SELECT records.*, categories.* FROM records LEFT JOIN categories ON records.category_id = categories.category_id WHERE records.category_id = :category_id ORDER BY record_id DESC LIMIT {$limit} OFFSET ".$offset); $statement->bindParam('category_id', $getCategoryId); $statement->execute(); $results = $statement->fetchAll(PDO::FETCH_ASSOC); If I remove try and catch block, it'll tell me exactly which line is giving the issue. So from the above code, the error has to do with "$statement->execute();". This is where the error occurs. As far as I know, the above pdo statement is correct. Can you tell me if something is wrong with it?
  12. Hello everyone. It seems like my code is not working properly. i have tried both mysqli and PDO to insert data into database,but it only takes me back to same page again,without doing nothing in the database (been checking this a few times to be sure). both php and html code are on the same page. Could anyone point me to the missing link in my code? here's my code (HTML & PHP) : <form action="" id="SignUpForm" autocomplete="on" style="display:none" method="post"> <!-- Form is Hidden until the user is clicking the "Sign Up" button. --> <input type="hidden" name="Language" value="English"> Fill up the following fields:<br><br> First name:<input type="text" name="fname" required><br><br> Last name: <input type="text" name="lname" required><br><br> Age: <input type="number" name="UserAge" min="1" max="120" required><br><br> Gender: <input type="radio" name="Gender" value="male">Male<br> <input type="radio" name="Gender" value="Female">Female<br> E-mail Address: <input type="email" name="email" autocomplete="off" required><br><br> Pick your new password: <input type="password" maxlength=”40” name="Password" required pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,40}"> Add password strength checker here.<br><br> <!-- Uses regular expression. --> Confirm Password: <input type="password" maxlength=”40” name="ConfirmPassword" required pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,40}"><br><br> <!-- A better way is to use onblur to check user's type match. --> <hr> <script> (function(){ $("#submit").click(function(){ $(".error").hide(); //Bind an event handler to the "error" JavaScript event. var hasError = false; var passwordVal = $("#Password").val(); var checkVal = $("#ConfirmPassword").val(); if (passwordVal == '') { $("#Password").after('<span class="error">Please enter a password.</span>'); hasError = true; } else if (checkVal == '') { $("#ConfirmPassword").after('<span class="error">Please re-enter your password.</span>'); hasError = true; } else if (passwordVal != checkVal ) { $("#ConfirmPassword").after('<span class="error">Passwords do not match.</span>'); hasError = true; } if(hasError == true) {return false;} }); }); </script> <script> //The validationMessage property of a DOM node contains the message the browser displays to the user when a node's validity is checked and fails. document.getElementById("name").validationMessage; document.getElementById("lname").validationMessage; document.getElementById("UserAge").validationMessage; document.getElementById("Gender").validationMessage; document.getElementById("email").validationMessage; document.getElementById("Password").validationMessage; document.getElementById("ConfirmPassword").validationMessage; </script> Now let's go through your prefered food. Check the appropriate boxed beyond.<br><br> This will help us to better understand your food discipline:<br> <p style="text-align:center"><b> Meat And Poultry:</b></p> <div id="MeatCheckBox"> <input type="checkbox" name="FoodTypes[]" value="Hamburger">Hamburger<br> <input type="checkbox" name="FoodTypes[]" value="Steak">Steak<br> <input type="checkbox" name="FoodTypes[]" value="GroundBeef">Ground Beef<br> <input type="checkbox" name="FoodTypes[]" value="Bacon">Bacon<br> <input type="checkbox" name="FoodTypes[]" value="Beef">Beef<br> <input type="checkbox" name="FoodTypes[]" value="Salami">Salami<br> <input type="checkbox" name="FoodTypes[]" value="Chicken">Chicken (In all its forms)<br> <input type="checkbox" name="FoodTypes[]" value="NoMeat">I don't eat meat at all (Vegeterian/Vegan)<br> </div> <p style="text-align:center"><b> Fish And Seafood:</b></p> <div id="FishAndSeaFood"> <input type="checkbox" name="FoodTypes[]" value="Fish">Fish<br> <input type="checkbox" name="FoodTypes[]" value="Sushi">Sushi<br> <input type="checkbox" name="FoodTypes[]" value="CannedFish">Canned Fish<br> <input type="checkbox" name="FoodTypes[]" value="Oysters">Seafood<br> <input type="checkbox" name="FoodTypes[]" value="SmokedSalmon">Smoked Salmon<br> </div> <div id="Vegetables"> <p style="text-align:center"><b> Do you eat vegtables?</b></p><br> <input type="radio" name="YesOrNo" value="Yes">Yes <!-- Give both options the same name,Because they are related. --> <input type="radio" name="YesOrNo" value="No">No<br> </div> <hr> <p>Do you workout as part of your lifestyle?</p><br> <input type="radio" name='workout_options' value='valuable' data-id="DoWorkout" class="workout_options" /> I do workout occasionally <input type="radio" name='workout_options' value='valuable' data-id="DoNotWorkout" class="workout_options" /> I am not working out<br><br><br> <section> <div id=DoWorkout class="workout_options"><p>We see you're not having any exercise at the moment.<br><br>Did you know that doing some kind of activity like running or cardio 3 times a week improve your life quality?<br><br>We'll help you go straight from zero to hero!</p></div> <div id=DoNotWorkout class="workout_options">What type of workout you're working on at the moment? Please choose from the options beyond:<br><br><br> <input type="checkbox" name="Cardio" value="Cardio" data-id="Cardio"/>Cardio/Aerobics<br><br> <input type="checkbox" name=" Weight_Lifting" value=" Weight_Lifting" data-id="Weight_Lifting"/>Weight Lifting/ Anaerobics</div><br> </section> <input type="submit" value="Sign Up!" id="submit"> </div> </form> PHP/PDO: <?php // connnecting to MYSQL with PDO. // Connection data (server_address, database, username, password) $hostdb = 'localhost'; $namedb = 'caf_users'; $userdb = 'root'; $passdb = 'mypassword'; if (isset($_POST['SignUpButton'])) { $yesOrNo=$_POST["YesOrNo"]; $firstName=$_POST["fname"]; $lastName=$_POST["lname"]; $userGender=$_POST["Gender"]; $emailAddress=$_POST["email"]; //check if user entered the exact password twice. if ($_POST["password"] === $_POST["confirm_password"]) { $password=$_POST["password"]; $hash = password_hash($passwod, PASSWORD_DEFAULT);} // The first parameter is the password string that needs to be hashed, //and the second parameter specifies the algorithm that should be used for generating the hash. //encrypted by bcrypt algorithm. else { echo "Passwords are mismatched. Please try again."; }; $userAge=$_POST["UserAge"]; // Display message if successfully connect, otherwise retains and outputs the potential error try { $conn = new PDO("mysql:host=$hostdb; dbname=$namedb", $userdb, $passdb); //Initiate connection witht the PDO object instance. $conn->exec("SET CHARACTER SET utf8"); // Sets encoding UTF-8 echo 'Connected to database'; // Define an insert query $sql = "INSERT INTO `users` ('Workout','first_name','last_name','gender','Email_Address','Password','User_Age') VALUES ($YesOrno,$fname,$lname,$Gender,$email,$password,$UserAge)"; $count = $conn->exec($sql); $conn = null; // Disconnect if($count !== false) echo 'Number of rows added: '. $count; } catch(PDOException $e) { echo $e->getMessage(); } } ?> Thank you in advance, Osher.
  13. db table username------>id->username->cash->points->referrer db table referral_levels------>id->level->earnings->signupBonusCash->signupBonusPoints->status username referrer -------- -------- admin kelly88 admin // UPDATE USERNAME ADMIN WITH referral level 1 POINTS/CASH // jacob kelly88 // UPDATE USERNAME ADMIN WITH referral level 2 POINTS/CASH AND USERNAME kelly88 WITH referral level 1 POINTS/CASH // david16 jacob // UPDATE USERNAME ADMIN WITH referral level 3 POINTS/CASH AND USERNAME kelly88 WITH referral level 2 POINTS/CASH AND USERNAME jacob WITH referral level 1 POINTS/CASH // Is this possible. If yes - HOW? Current test registration code with referral level 1 <?php if(!empty($_GET['ref'])){ $referrerUsername = filter_input(INPUT_GET, 'ref', FILTER_SANITIZE_STRING); if(usernameExist($referrerUsername, $db) === TRUE){ $_SESSION['ref'] = $referrerUsername; } } // define variables with the value for each field // the value from POST,GET if this exist, or an empty value $errors = array(); $username = isset($_POST['username']) ? filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING) : ''; $referrer = !empty($_SESSION['ref']) ? $_SESSION['ref'] : (isset($_POST['referrer']) ? filter_input(INPUT_POST, 'referrer', FILTER_SANITIZE_STRING) : ''); if(!empty($_POST['submit'])){ if(empty($username)){ $errors[] = $lang['error']['a_019']; } else if(validUsernameLenght($username) === FALSE){ $errors[] = $lang['error']['a_020']; } else if(validUsernameChars($username) === FALSE){ $errors[] = $lang['error']['a_021']; } else if(usernameExist($username, $db) === TRUE){ $errors[] = $lang['error']['a_022']; } if(!empty($referrer)){ if(usernameExist($referrer, $db) === FALSE){ $errors[] = $lang['error']['a_037']; } else if($username == $referrer){ $errors[] = $lang['error']['a_038']; } } } if(!empty($_POST['submit']) and empty($errors)){ /* $queryOne = 'INSERT INTO users(username, referrer) VALUES (:username, :referrer)'; $insertOne = $db->prepare($queryOne); $insertOne->bindParam(':username', $username, PDO::PARAM_STR); $insertOne->bindParam(':referrer', $referrer, PDO::PARAM_STR); $successOne = $insertOne->execute(); */ if($referrer){ $query = 'SELECT signupBonusCash AS sbc, signupBonusPoints AS sbp FROM referral_levels WHERE level = 1 AND status = "enabled"'; $select = $db->query($query); $row = $select->fetch(PDO::FETCH_ASSOC); $queryTwo = 'UPDATE users SET points = points + :points, cash = cash + :cash WHERE username = :referrer'; $selectTwo = $db->prepare($queryTwo); $selectTwo->bindParam(':cash', $row['sbc'], PDO::PARAM_STR); $selectTwo->bindParam(':points', $row['sbp'], PDO::PARAM_STR); $selectTwo->bindParam(':referrer', $referrer, PDO::PARAM_STR); $selectTwo->execute(); } } if(!empty($errors)){ foreach($errors as $error){ print $error.'<br>'; } } print ' <form method="POST"> <table style="width:100%"> <tr> <td style="width:30%;font-weight:bold">Username</td> <td style="width:70%"><input type="text" name="username" maxlength="255" style="width:200px" value="'.cleanOutput($username).'"></td> </tr>'; if(!empty($_SESSION['ref'])){ print ' <tr> <td style="font-weight:bold">'.$lang['global']['a_047'].'</td> <td><input type="text" name="referrer" readonly="readonly" maxlength="255" style="width:200px" value="'.cleanOutput($referrer).'"></td> </tr>'; }else{ print ' <tr> <td style="font-weight:bold">'.$lang['global']['a_047'].'</td> <td><input type="text" name="referrer" maxlength="255" style="width:200px" value="'.cleanOutput($referrer).'"></td> </tr>'; } print ' <tr> <td colspan="2" style="text-align:center"><input type="submit" name="submit" value="Submit"></td> </tr> </table> </form>'; ?>
  14. I am using WAMP server for my PHP Server and am trying to connect to an Access Database with the extension of accdb, but I keep getting the error "could not find driver". Here is the code I'm trying to run: $dbName = $_SERVER["DOCUMENT_ROOT"]."/Ridley/RLCompRepair.accdb"; if (!file_exists($dbName)) { die("Could not find database file."); } try { $db = new PDO("odbc:Driver={MS Access Database (*.mdb, *.accdb)};Dbq=$dbName"); } catch (PDOException $e) { echo "Error: ".$e->getMessage(); } I have enabled the php_pdo_odbc extension, so I'm pretty sure this is not the problem. Could someone please let me know what is wrong? Chris
  15. i've use php-event-calender for showing event from table.when i click on event date, it's dispay table details for relevent date correctly in localhost.but it's didn't show details in live server. index.php <div id="Calendar"> </div> <div id="Events"> </div> <script language="javascript" src="calendar.js"></script> calender.php <?php error_reporting(0); include("config.php"); /// get current month and year and store them in $cMonth and $cYear variables (intval($_REQUEST["month"])>0) ? $cMonth = intval($_REQUEST["month"]) : $cMonth = date("m"); (intval($_REQUEST["year"])>0) ? $cYear = intval($_REQUEST["year"]) : $cYear = date("Y"); // generate an array with all dates with events $sql = "SELECT * FROM reservation WHERE arrival LIKE '".$cYear."-".$cMonth."-%'"; $result = db::getInstance()->query($sql); while ($row = $result->fetch()) { $events[$row["arrival"]]["f_name"] = $row["f_name"]; $events[$row["arrival"]]["l_name"] = $row["l_name"]; } // calculate next and prev month and year used for next / prev month navigation links and store them in respective variables $prev_year = $cYear; $next_year = $cYear; $prev_month = intval($cMonth)-1; $next_month = intval($cMonth)+1; // if current month is December or January month navigation links have to be updated to point to next / prev years if ($cMonth == 12 ) { $next_month = 1; $next_year = $cYear + 1; } elseif ($cMonth == 1 ) { $prev_month = 12; $prev_year = $cYear - 1; } if ($prev_month<10) $prev_month = '0'.$prev_month; if ($next_month<10) $next_month = '0'.$next_month; ?> <table width="100%" style="width:800px;height:600px;background-color:#FFFFFF;"> <tr> <td class="mNav"><a href="javascript:LoadMonth('<?php echo $prev_month; ?>', '<?php echo $prev_year; ?>')"><<</a></td> <td colspan="5" class="cMonth"><?php echo date("F, Y",strtotime($cYear."-".$cMonth."-01")); ?></td> <td class="mNav"><a href="javascript:LoadMonth('<?php echo $next_month; ?>', '<?php echo $next_year; ?>')">>></a></td> </tr> <tr> <td class="wDays">M</td> <td class="wDays">T</td> <td class="wDays">W</td> <td class="wDays">T</td> <td class="wDays">F</td> <td class="wDays">S</td> <td class="wDays">S</td> </tr> <?php $first_day_timestamp = mktime(0,0,0,$cMonth,1,$cYear); // time stamp for first day of the month used to calculate $maxday = date("t",$first_day_timestamp); // number of days in current month $thismonth = getdate($first_day_timestamp); // find out which day of the week the first date of the month is $startday = $thismonth['wday'] - 1; // 0 is for Sunday and as we want week to start on Mon we subtract 1 for ($i=0; $i<($maxday+$startday); $i++) { if (($i % 7) == 0 ) echo "<tr>"; if ($i < $startday) { echo "<td> </td>"; continue; }; $current_day = $i - $startday + 1; if ($current_day<10) $current_day = '0'.$current_day; // set css class name based on number of events for that day if ($events[$cYear."-".$cMonth."-".$current_day]<>'') { $css='withevent'; $click = "onclick=\"LoadEvents('".$cYear."-".$cMonth."-".$current_day."')\""; } else { $css='noevent'; $click = ''; } echo "<td class='".$css."'".$click.">". $current_day . "</td>"; if (($i % 7) == 6 ) echo "</tr>"; } ?> </table> events.php <?php error_reporting(0); include("config.php"); $sql = "SELECT * FROM reservation WHERE arrival = '".mysql_real_escape_string($_REQUEST["date"])."' AND status='pending'"; $result = db::getInstance()->query($sql); while ($row = $result->fetch()) { echo "<h2>"."Reservation ID :"." ".$row["res_id"]."</h2>"; echo "<b>"."Client Name :"."</b>"."<span>".$row["f_name"]." ".$row["l_name"]."</span>"."</br>"; echo "<b>"."Address :"."</b>"."<span>".$row["address"]."</span>"."</br>"; echo "<b>"."City :"."</b>"."<span>".$row["city"]."</span>"."</br>"; echo "<b>"."Zip :"."</b>"."<span>".$row["zip"]."</span>"."</br>"; echo "<b>"."Country :"."</b>"."<span>".$row["country"]."</span>"."</br>"; echo "<b>"."E-mail :"."</b>"."<span>".$row["email"]."</span>"."</br>"; echo "<b>"."Contact No :"."</b>"."<span>".$row["contact"]."</span>"."</br>"; echo "<b>"."In Date :"."</b>"."<span>".$row["arrival"]."</span>"."</br>"; echo "<b>"."Out Date :"."</b>"."<span>".$row["departure"]."</span>"."</br>"; echo "<b>"."Total Price :"."</b>"."<span>".$row["tot_price"]."</span>"."</br>"; echo "<b>"."Room Id :"."</b>"."<span>".$row["room_id"]."</span>"."</br>"; echo "<b>"."No Of Beds :"."</b>"."<span>".$row["no_beds"]."</span>"."</br>"; } ?> live server show calender and event date fine.but didn't show event details for that date.it's show correctly in localserver.
  16. I have displayed check box values(ugroup field) from ugroups table.now what i want to do is,when user select multiple check boxes and submit it should be insert into relavent feild in table.now it's insert check boxes values.but not in relevant field.this is my code.Please help me. //select ugroup's from group table. <?php $result = "SELECT id,ugroup FROM group"; $res_result = db::getInstance()->query($result); ?> <form action="db_sql/db_add_page.php" method="get"> Tittle :<input type="text" size="100" name="tittle" /> Description :<textarea cols="80" id="editor1" name="description" rows="10"></textarea> //Display ugroups in textboxes and checkboxes <?php while( $line=$res_result->fetch(PDO::FETCH_ASSOC)) { echo '<input type="checkbox" name="group[]" value=" '. $line['ugroup'] .'" />'; echo'<input type="text" name="ugroup" disabled="disabled" value=" '. $line['ugroup'] .'" size="7" "/>'; echo ' '; } ?><input type="submit" value="Submit"> </form> db_add_page.php if(isset($_POST)) { $tittle = $_POST['tittle']; $description = $_POST['description']; $ugroup = $_POST['group']; $acc_status = "INSERT INTO add_services (id,tittle,description,g1,g2,g3,g4,g5,g6,g7,g8) VALUES(NULL,'".$tittle."','".$description."','".$ugroup[0]."','".$ugroup[1]."','".$ugroup[2]."',' ".$ugroup[3]."','".$ugroup[4]."','".$ugroup[5]."','".$ugroup[6]."','".$ugroup[7]."')"; $rate = db::getInstance()->exec($acc_status); if(!$rate){ echo '<script type="text/javascript">alert("Update Error !");</script>'; }else{ header('Location:../add_page.php'); echo '<script type="text/javascript">alert("Successfuly Updated User Group !");</script>'; } }
  17. I have included language file and function file in my index.php include 'includes/functions.php'; include 'languages/english.php'; english.php contains <?php $lang['success']['a'] = 'Settings have been updated.'; $lang['error']['b'] = 'Database error. Please try again later!'; ................................. ?> functions.php <?php function testFunction($id, $settings, $db){ $query = 'UPDATE table_name SET a = a + :a WHERE id = :id'; $update = $db->prepare($query); $update->bindParam(':a', $settings['a'], PDO::PARAM_INT); $update->bindParam(':id', $id, PDO::PARAM_INT); $success = $update->execute(); if($success){ print $lang['success']['a']; }else{ print $lang['error']['b']; } } ................................................. ?> Now if i print testFunction(); i got Undefined variable: lang in ............. If i include 'languages/english.php'; in testFunction() then everything works. Any other way to make $lang working without including language file in testFunction(). (Sorry for my bad english) print testfunction(2, $settings, $db);
  18. Hi, I want to display row 0 row 2 row 3 and row 4 values in to text field.this is my code.but it's display "Undefined offset: 1 in C:\wamp\www\member\sys-admin\groups.php on line 15 ,Undefined offset: 2 in C:\wamp\www\member\sys-admin\groups.php on line 16 ,Undefined offset: 3 in C:\wamp\www\member\sys-admin\groups.php on line 17". <?php $r_sql = "SELECT ugroup FROM ugroups "; $r_result = db::getInstance()->query($r_sql); $row = $r_result->fetch(PDO::FETCH_NUM); $g1 = $row['0']; $g2 = $row[1]; $g3 = $row[2]; $g4 = $row[3]; ?> html <strong>G 1</strong><input name="g1" type="text" id="g1" style="width:300px;" value="<?php echo $g1; ?>" /> <strong>G 2</strong> <input name="g2" type="text" id="g2" style="width:300px;" value="<?php echo $g2; ?>" /> <strong>G 3</strong><input name="g3" type="text" id="g3" style="width:300px;" value="<?php echo $g3; ?>" /> <strong>G 4</strong><input name="g4" type="text" id="g4" style="width:300px;" value="<?php echo $g4; ?>" />
  19. Code what i made so far. Your comments at what should i do differently. My configs.php <?php $userQuery = 'SELECT * FROM users WHERE id = :id'; $user = $db->prepare($userQuery); $user->bindParam(':id', $_SESSION['userId'], PDO::PARAM_INT); $user->execute(); $userInfo = $user->fetch(PDO::FETCH_ASSOC); ?> functions.php <?php function loginCheck(){ global $db; if(isset($_SESSION['userId'], $_SESSION['loginString'])){ $query = 'SELECT username FROM users WHERE id = :id'; $user = $db->prepare($query); $user->bindParam(':id', $_SESSION['userId'], PDO::PARAM_INT); $user->execute(); $row = $user->fetch(PDO::FETCH_ASSOC); if($user->rowCount() == 1){ if(hash('sha512', $row['username'].$_SERVER['HTTP_USER_AGENT']) == $_SESSION['loginString']){ return true; }else{ return false; } }else{ return false; } }else{ return false; } } function checkUserRole(){//can be user, admin and moderator global $userInfo; if($userInfo['userRole'] == 'admin' or $userInfo['userRole'] == 'moderator'){ return true; }else{ return false; } } ?> shoutbox.php Can this be done with one query? global $db, $userInfo; $sbQuery = 'SELECT * FROM shoutbox ORDER BY dateCreated DESC LIMIT 30'; $sb = $db->query($sbQuery); $usersQuery = 'SELECT * FROM users WHERE shoutBoxBan = "yes"'; $users= $db->query($usersQuery); $usersRow = $users->fetch(PDO::FETCH_ASSOC); $hiddenAction = ''; while($sbRow = $sb->fetch(PDO::FETCH_ASSOC)){ if(loginCheck() and checkUserRole()){ $hiddenAction = " <a href=\"javascript:;\" onClick=\"deleteMessage('".$sbRow['id']."')\" class=\"shoutBoxDelete\" title=\"Delete\">x</a>"; if($usersRow['username'] == $sbRow['username']){ $hiddenAction .= " <a href=\"javascript:;\" onClick=\"unBan('".$sbRow['username']."')\" class=\"shoutBoxBan\" title=\"Unban\">u</a>"; }else{ if($userInfo['username'] != $sbRow['username']){//admin and moderator cant ban themselves. $hiddenAction .= " <a href=\"javascript:;\" onClick=\"banUser('".$sbRow['username']."')\" class=\"shoutBoxBan\" title=\"Ban\">o</a>"; $hiddenAction .= " <a href=\"javascript:;\" onClick=\"tempBanUser('".$sbRow['username']."')\" class=\"shoutBoxBan\" title=\"Temp Ban\">ø</a>"; } } } ....................................
  20. Doesn't change status to expired. <?php $bannersQuery = 'SELECT * FROM banners WHERE expire > NOW() AND status = "active" ORDER BY RAND() LIMIT 10'; $banners = $db->query($bannersQuery); while($row = $banners->fetch(PDO::FETCH_ASSOC)){ if($row['expire'] <= time()){ $status = 'expired'; }else{ $status = 'active'; } $updateQuery = 'UPDATE banners SET exposures = exposures + 1, status = :status WHERE id = :id'; $update = $db->prepare($updateQuery); $update->bindParam(':status', $status, PDO::PARAM_STR); $update->bindParam(':id', $row['id'], PDO::PARAM_INT); $update->execute(); echo ' <a href="index.php?do=bannerClick&id='.$row['id'].'" target="_BLANK"><img src="'.$row['url'].'" width="'.$row['width'].'" height="'.$row['height'].'" alt="'.$row['title'].'"></a><br>'; } echo ' <a href="index.php?do=buyBanner">Want to advertise your banner? Click here.</a>'; ?>
  21. <?php if(isset($_POST['submit'])){ $uname = $_POST['username']; $pword = $_POST['password']; /*** mysql hostname ***/ $hostname = 'localhost'; /*** mysql username ***/ $username = 'root'; /*** mysql password ***/ $password = 'anty90'; try { $link = new PDO("mysql:host=$hostname;dbname=gambling", $username, $password); /*** echo a message saying we have connected ***/ echo 'Connected to database<br />'; /*** INSERT data ***/ $stmt = $link->prepare("INSERT INTO gamb(username, password) VALUES (?, ?)"); try{ $stmt->execute(array("$uname", "$pword")); } catch(PDOException $e){ echo "Exception caught: $e"; } /*** echo the number of affected rows ***/ //echo $count; /*** close the database connection ***/ $link = null; } catch(PDOException $e) { echo $e->getMessage(); } } ?> <html> <form action='home.php' method='post'> <input type="text" name="username" > <input type="password" name="password" > <input type="submit" name="submit" value="submit"> </form> </html> I'm new to databse programming so I was just wondering if this was vulnerable to sql injection or not.
  22. How to display items like bottom table? And here is the code <? print" <table style=\"width:100%\" class=\"tableList\"> <tr> <th style=\"width:35%\">Prize Name</th> <th style=\"width:12%\">Amount</th> <th style=\"width:12%\">Points</th> <th style=\"width:12%\">Available</th> <th style=\"width:12%\">Redeemed</th> <th style=\"width:17%\">Action</th> </tr>"; $giftCardQuery = 'SELECT currency, amount, pointsPrice, instant_gift_cards.id, instant_gift_cards.giftCardName, instant_gift_cards.giftCardImage FROM instant_gift_card_codes INNER JOIN instant_gift_cards ON (instant_gift_card_codes.giftCardId = instant_gift_cards.id) WHERE instant_gift_cards.status = :cardStatus ORDER BY instant_gift_cards.dateCreated DESC'; $giftCard = $db->prepare($giftCardQuery); $giftCard->bindValue(':cardStatus', 'Enabled', PDO::PARAM_STR); $giftCard->execute(); if($giftCard->rowCount() > '0'){ while($giftCardRow = $giftCard->fetch(PDO::FETCH_ASSOC)){ $giftCardsAvailableQuery = 'SELECT count(*) FROM instant_gift_card_codes WHERE currency = :currency AND amount = :amount AND pointsPrice = :pointsPrice AND giftCardId = :id AND status = :status'; $giftCardsAvailable = $db->prepare($giftCardsAvailableQuery); $giftCardsAvailable->bindParam(':currency', $giftCardRow['currency'], PDO::PARAM_STR); $giftCardsAvailable->bindParam(':amount', $giftCardRow['amount'], PDO::PARAM_STR); $giftCardsAvailable->bindParam(':pointsPrice', $giftCardRow['pointsPrice'], PDO::PARAM_STR); $giftCardsAvailable->bindParam(':id', $giftCardRow['id'], PDO::PARAM_INT); $giftCardsAvailable->bindValue(':status', 'Available', PDO::PARAM_STR); $giftCardsAvailable->execute(); $gCardsAvailable = $giftCardsAvailable->fetch(PDO::FETCH_COLUMN); $giftCardsRedeemedQuery = 'SELECT count(*) FROM instant_gift_card_codes WHERE currency = :currency AND amount = :amount AND pointsPrice = :pointsPrice AND giftCardId = :id AND status = :status'; $giftCardsRedeemed = $db->prepare($giftCardsRedeemedQuery); $giftCardsRedeemed->bindParam(':currency', $giftCardRow['currency'], PDO::PARAM_STR); $giftCardsRedeemed->bindParam(':amount', $giftCardRow['amount'], PDO::PARAM_STR); $giftCardsRedeemed->bindParam(':pointsPrice', $giftCardRow['pointsPrice'], PDO::PARAM_STR); $giftCardsRedeemed->bindParam(':id', $giftCardRow['id'], PDO::PARAM_INT); $giftCardsRedeemed->bindValue(':status', 'Redeemed', PDO::PARAM_STR); $giftCardsRedeemed->execute(); $gCardsRedeemed = $giftCardsRedeemed->fetch(PDO::FETCH_COLUMN); if($giftCardRow['giftCardImage']){ $nameOrImage = '<img src="./images/giftcardrewards/'.$giftCardRow['giftCardImage'].'" alt="'.$giftCardRow['giftCardName'].'" title="'.$giftCardRow['giftCardName'].'">'; }else{ $nameOrImage = $giftCardRow['giftCardName']; } if($gCardsAvailable == '0'){ $redeemAction = 'Out of Stock'; } elseif($userInfo['currentPoints'] < $giftCardRow['pointsPrice']){ $needed = $giftCardRow['pointsPrice'] - $userInfo['currentPoints']; $redeemAction = 'You need '.$needed.' point(s)'; } elseif($userInfo['currentPoints'] >= $giftCardRow['pointsPrice']){ $redeemAction = '<input type="button" value="Redeem" onclick="if(confirm(\'Are you sure to redeem this prize?\')){location.href=\'index.php?do=instantGiftCards&action=redeem&cardId='.$giftCardRow['id'].'&amount='.$giftCardRow['amount'].'\';}">'; } print" <tr> <td>".$nameOrImage."</td> <td style=\"text-align:center\">".$giftCardRow['currency'].$giftCardRow['amount']."</td> <td style=\"text-align:center\">".$giftCardRow['pointsPrice']."</td> <td style=\"text-align:center\">".$gCardsAvailable."</td> <td style=\"text-align:center\">".$gCardsRedeemed."</td> <td style=\"text-align:center\">".$redeemAction."</td> </tr>"; } }else{ print" <tr> <td colspan=\"4\" style=\"text-align:center;color:#2B1B17;padding:15px 0\">No prizes added.</td> </tr>"; } print" </table>"; ?>
  23. the sql statement dont execute: what would be the problem? $sql = "UPDATE ".prefix("loanapplication")." SET firstname = :firstname, secondname = :secondname, surname = :surname, officialworkemail = :officialworkemail"; $sql.= " WHERE username=:username"; $sql.= " WHERE username=:username"; echo "$sql: $sql<br>"; //print_r($sql); $stmt = $database->connection->prepare($sql); $stmt->bindParam(':username',$session->username); $stmt->bindParam(':firstname',$firstname); $stmt->bindParam(':secondname',$secondname); $stmt->bindParam(':surname',$surname); $stmt->bindParam(':officialworkemail',$officialworkemail); $stmt->execute(); sql =UPDATE `emr_loanapplication` SET firstname = :firstname, secondname = :secondname, surname = :surname, officialworkemail = :officialworkemail WHERE username=:username
  24. Can I get some help or a point in the right direction. I am trying to create a form that allows me to add, edit and delete records from a database. I can add, edit and delete if I dont include the image upload code. If I include the upload code I cant edit records without having to upload the the same image to make the record save to the database. So I can tell I have got the code processing in the wrong way, thing is I cant seem to see or grasp the flow of this, to make the corrections I need it work. Any help would be great! Here is the form add.php code <?php require_once ("dbconnection.php"); $id=""; $venue_name=""; $address=""; $city=""; $post_code=""; $country_code=""; $url=""; $email=""; $description=""; $img_url=""; $tags=""; if(isset($_GET['id'])){ $id = $_GET['id']; $sqlLoader="Select from venue where id=?"; $resLoader=$db->prepare($sqlLoader); $resLoader->execute(array($id)); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Add Venue Page</title> <link href='http://fonts.googleapis.com/css?family=Droid+Sans' rel='stylesheet' type='text/css'> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <?php $sqladd="Select * from venue where id=?"; $resadd=$db->prepare($sqladd); $resadd->execute(array($id)); while($rowadd = $resadd->fetch(PDO::FETCH_ASSOC)){ $v_id=$rowadd['id']; $venue_name=$rowadd['venue_name']; $address=$rowadd['address']; $city=$rowadd['city']; $post_code=$rowadd['post_code']; $country_code=$rowadd['country_code']; $url=$rowadd['url']; $email=$rowadd['email']; $description=$rowadd['description']; $img_url=$rowadd['img_url']; $tags=$rowadd['tags']; } ?> <h1 class="edit-venue-title">Add Venue:</h1> <form role="form" enctype="multipart/form-data" method="post" name="formVenue" action="save.php"> <input type="hidden" name="id" value="<?php echo $id; ?>"/> <div class="form-group"> <input class="form-control" type="hidden" name="id" value="<?php echo $id; ?>"/> <p><strong>ID:</strong> <?php echo $id; ?></p> <strong>Venue Name: *</strong> <input class="form-control" type="text" name="venue_name" value="<?php echo $venue_name; ?>"/><br/> <br/> <strong>Address: *</strong> <input class="form-control" type="text" name="address" value="<?php echo $address; ?>"/><br/> <br/> <strong>City: *</strong> <input class="form-control" type="text" name="city" value="<?php echo $city; ?>"/><br/> <br/> <strong>Post Code: *</strong> <input class="form-control" type="text" name="post_code" value="<?php echo $post_code; ?>"/><br/> <br/> <strong>Country Code: *</strong> <input class="form-control" type="text" name="country_code" value="<?php echo $country_code; ?>"/><br/> <br/> <strong>URL: *</strong> <input class="form-control" type="text" name="url" value="<?php echo $url; ?>"/><br/> <br/> <strong>Email: *</strong> <input class="form-control" type="email" name="email" value="<?php echo $email; ?>"/><br/> <br/> <strong>Description: *</strong> <textarea class="form-control" type="text" name="description" rows ="7" value=""><?php echo $description; ?></textarea><br/> <br/> <strong>Image Upload: *</strong> <input class="form-control" type="file" name="image" value="<?php echo $img_url; ?>"/> <small>File sizes 300kb's and below 500px height and width.<br/><strong>Image is required or data will not save.</strong></small> <br/><br/> <strong>Tags: *</strong> <input class="form-control" type="text" name="tags" value="<?php echo $tags; ?>"/><small>comma seperated vales only, e.g. soul,hip-hop,reggae</small><br/> <br/> <p>* Required</p> <br/> <input class="btn btn-primary" type="submit" name="submit" value="Save"> </div> </form> </div> </body> </html> Here is the save.php code <?php error_reporting(E_ALL); ini_set("display_errors", 1); include ("dbconnection.php"); $venue_name=$_POST['venue_name']; $address=$_POST['address']; $city=$_POST['city']; $post_code=$_POST['post_code']; $country_code=$_POST['country_code']; $url=$_POST['url']; $email=$_POST['email']; $description=$_POST['description']; $tags=$_POST['tags']; $id=$_POST['id']; if(is_uploaded_file($_FILES['image']['tmp_name'])){ $folder = "images/hs-venues/"; $file = basename( $_FILES['image']['name']); $full_path = $folder.$file; if(move_uploaded_file($_FILES['image']['tmp_name'], $full_path)) { //echo "succesful upload, we have an image!"; var_dump($_POST); if($id==null){ $sql="INSERT INTO venue(venue_name,address,city,post_code,country_code,url,email,description,img_url,tags)values(:venue_name,:address,:city,:post_code,:country_code,:url,:email,:description,:img_url,:tags)"; $qry=$db->prepare($sql); $qry->execute(array(':venue_name'=>$venue_name,':address'=>$address,':city'=>$city,':post_code'=>$post_code,':country_code'=>$country_code,':url'=>$url,':email'=>$email,':description'=>$description,':img_url'=>$full_path,':tags'=>$tags)); }else{ $sql="UPDATE venue SET venue_name=?, address=?, city=?, post_code=?, country_code=?, url=?, email=?, description=?, img_url=?, tags=? where id=?"; $qry=$db->prepare($sql); $qry->execute(array($venue_name, $address, $city, $post_code, $country_code, $url, $email, $description, $full_path, $tags, $id)); } if($success){ var_dump($_POST); echo "<script language='javascript' type='text/javascript'>alert('Successfully Saved!')</script>"; echo "<script language='javascript' type='text/javascript'>window.open('index.php','_self')</script>"; } else{ var_dump($_POST); echo "<script language='javascript' type='text/javascript'>alert('Successfully Saved!')</script>"; echo "<script language='javascript' type='text/javascript'>window.open('index.php','_self')</script>"; } } //if uploaded else{ var_dump($_POST); echo "<script language='javascript' type='text/javascript'>alert('Upload Recieved but Processed Failed!')</script>"; echo "<script language='javascript' type='text/javascript'>window.open('index.php','_self')</script>"; } } //move uploaded else{ var_dump($_POST); echo "<script language='javascript' type='text/javascript'>alert('Successfully Updated.')</script>"; echo "<script language='javascript' type='text/javascript'>window.open('index.php','_self')</script>"; } ?> Thanks in advance!
  25. My code; $sql = "SELECT SUM(IF(`submitdate` IS NULL , 1 , 0 )) as 'Survey Started But Not Completed' FROM `survey_$surveyid`"; $statement = $dbh->prepare($sql); $statement->execute(); $result = $statement->fetch(PDO::FETCH_OBJ); //pass that data to an object Is returning; stdClass Object ( [Survey Started But Not Completed] => )  I need to set this to a vaule that I can actually print out on the screen... Like a "0" for example. At the moment it is just a NULL. How do I do this?? These don't work; $result = 0; $result = array(['Survey Started But Not Completed'] => "0");
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.