Jump to content

cabbie

Members
  • Posts

    32
  • Joined

  • Last visited

cabbie's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Everything works but the SELECT COUNT $q = $db->prepare("SELECT COUNT(id) as records FROM tracker WHERE que_id = 3"); $q->execute(); $records = (int) $q->fetch(PDO::FETCH_OBJ)->records; echo '$records =', $records;
  2. This is close.... http://pastebin.com/rqSVNBFV
  3. Originally que_id was the increment variable and i was passing between pages. the table tracker has 2 columns id (not auto incremented) and que_id. each operator after login will start at the current que_id or id.. Yes I had where Que_id= que_id but changed it As you can see I have put a lot of time in this project and way over my head trying to develop this code and pulling my hair. Syntax in this particular operation is the problem..
  4. This is a phone survey script... survey php prints the current reg voters data on the survey page. The surveyor attempts a call and gets a no answer or contact and Selects this result from a dropdown which calls operation.php. Operation.php increments the row id and stores it into table tracker. survey.php then prints the new data for the next call .. this code is almost working.. this is a link to the survey page. and link to the code below that. survey page http://libertarianpartylc.org/survey.php code http://pastebin.com/9dx04UDP
  5. I need que to be an integer value.. A number I can use math on. Ill provide a link to survey page Whatever the que is a query SELECTS the data in that row. What I want to do is on the next operation got to the next ID.. http://libertarianpartylc.org/survey.php
  6. I want to get a number from a data base use it in another script increment by 1 and insert back into that column. In this script how can I get the numeric value of que? $query = $db->query("SELECT `que` FROM `tracker` "); while($rows = $query->fetch(PDO::FETCH_ASSOC)){ echo $rows['que']; (prints que) echo que; (does not work)
  7. cabbie

    print_r

    Thanks.. I had to SELECT each one but that works..
  8. cabbie

    print_r

    Im doing a PDO query and need help with the while loop and printout. Without showing the whole script here is the code,, Need a printout similar to this.. I can do the html etc. A format easy to read for surveyor. Voter ID 9003256 Name John Doe Address 123 Main St Phone 5553123698 http://libertarian-forum.com/larimerlp/survey.php $query = $db->query("SELECT * FROM `members` WHERE `members` . `index` = $que"); $rows = $query->fretchAll(PDO::FETCH_ASSOC);
  9. What is the proper syntax or method in the prepare update sequence? <?php session_start(); $log_user_id = preg_replace('#[^0-9]#', '', $_SESSION['uid']); $username = $_SESSION['owner']; $fileName = $_FILES["uploaded_file"]["name"]; // The file name $fileTmpLoc = $_FILES["uploaded_file"]["tmp_name"]; // File in the PHP tmp folder $fileType = $_FILES["uploaded_file"]["type"]; // The type of file it is $fileSize = $_FILES["uploaded_file"]["size"]; // File size in bytes $fileErrorMsg = $_FILES["uploaded_file"]["error"]; // 0 for false... and 1 for true $kaboom = explode(".", $fileName); // Split file name into an array using the dot $fileExt = end($kaboom); // Now target the last array element to get the file extension // START PHP Image Upload Error Handling -------------------------------------------------- echo $username, $fileName; if (!$fileTmpLoc) { // if file not chosen echo "ERROR: Please browse for a file before clicking the upload button."; exit(); } else if($fileSize > 5242880) { // if file size is larger than 5 Megabytes echo "ERROR: Your file was larger than 5 Megabytes in size."; unlink($fileTmpLoc); // Remove the uploaded file from the PHP temp folder exit(); } else if (!preg_match("/.(gif|jpg|png)$/i", $fileName) ) { // This condition is only if you wish to allow uploading of specific file types echo "ERROR: Your image was not .gif, .jpg, or .png."; unlink($fileTmpLoc); // Remove the uploaded file from the PHP temp folder exit(); } else if ($fileErrorMsg == 1) { // if file upload error key is equal to 1 echo "ERROR: An error occured while processing the file. Try again."; exit(); } // END PHP Image Upload Error Handling --------------------------------- // Place it into your "uploads" folder mow using the move_uploaded_file() function $moveResult = move_uploaded_file($fileTmpLoc, "members/$username/$fileName"); // Check to make sure the move result is true before continuing if ($moveResult != true) { echo "ERROR: File not uploaded. Try again.", $fileName; unlink($fileTmpLoc); // Remove the uploaded file from the PHP temp folder exit(); } // ---------- Include Adams Universal Image Resizing Function -------- include_once("scripts/avatar_sizecrop.php"); $target_file = "members/$username/$fileName"; $resized_file = "members/$username/$fileName"; $wmax = 310; $hmax = 300; ak_img_resize($target_file, $resized_file, $wmax, $hmax, $fileExt); //$query = $db->query("UPDATE members SET avatar='$avatar' WHERE username='$username' AND id='$log_user_id' LIMIT 1"); // ----------- End Adams Universal Image Resizing Function ---------- // ------ Start Adams Universal Image Thumbnail(Crop) Function ------ /*$target_file = "members/$username/resized_$fileName"; $thumbnail = "members/$username/thumb_$fileName"; $wthumb = 150; $hthumb = 150; ak_img_thumb($target_file, $thumbnail, $wthumb, $hthumb, $fileExt); // ------- End Adams Universal Image Thumbnail(Crop) Function -------*/ // Display things to the page so you can see what is happening for testing purposes //header("Location: index.php?$username"); $updateSQL = $db->prepare("UPDATE members SET avatar=? WHERE username=? LIMIT 1"); $updateSQL->bindValue(1,$fileName,PDO::PARAM_INT); $updateSQL->bindValue(2,$username,PDO::PARAM_INT); $updateSQL->execute(); exit(); ?>
  10. cabbie

    php move

    This is what I needed .. $dstfile="members/{$user}/we.png";
  11. cabbie

    php move

    I am trying to copy a default avatar pic to a users folder which is generated during activation The above code generates the folder I want to copy the default avatar to that folder in the users profile This is the activation code I just need the copy syntax.. <?php if(isset($_GET['user']) && $_GET['user'] != "" && isset($_GET['token']) && $_GET['token'] != ""){ include_once("scripts/connect.php"); $user = preg_replace('#[^0-9]#', '', $_GET['user']); $token = preg_replace('#[^a-z0-9]#i', '', $_GET['token']); $stmt = $db->prepare("SELECT user, token FROM activate WHERE user=:user AND token=:token LIMIT 1"); $stmt->bindValue(':user',$user,PDO::PARAM_INT); $stmt->bindValue(':token',$token,PDO::PARAM_STR); try{ $stmt->execute(); $count = $stmt->rowCount(); if($count > 0){ try{ $db->beginTransaction(); $updateSQL = $db->prepare("UPDATE members SET activated='1' WHERE id=:user LIMIT 1"); $updateSQL->bindValue(':user',$user,PDO::PARAM_INT); $updateSQL->execute(); $deleteSQL = $db->prepare("DELETE FROM activate WHERE user=:user AND token=:token LIMIT 1"); $deleteSQL->bindValue(':user',$user,PDO::PARAM_INT); $deleteSQL->bindValue(':token',$token,PDO::PARAM_STR); $deleteSQL->execute(); if(!file_exists("members/$user")){ mkdir("members/$user", 0755); } $db->commit(); echo 'Your account has been activated! Click the link to log in: <a href="login.php">Log In</a>'; $db = null; exit(); } catch(PDOException $e){ $db->rollBack(); echo $e->getMessage(); } }else{ echo "Sorry, There has been an error. Maybe try registering again derp."; $db = null; exit(); } } catch(PDOException $e){ echo $e->getMessage(); $db = null; exit(); } } ?>
  12. Why do I get error on move or copy? <?php $user = "joe";mkdir("members/$user", 0777);$srcfile='images/we.png'; $dstfile='members/$user/we.png'; $moveResult = move_uploaded_file($srcfile, $dstfile); if ($moveResult != true) {echo 'failed';exit();}//copy($srcfile, $dstfile) or die("Unable to copy $srcfile to $dstfile."); echo $srcfile, $dstfile, '?/'; ?>
  13. cabbie

    ajax

    Ok I found out I didnt even have the right dir path to connect.php I have this code working..Last half is commented out .. echo 'fired', $row['username']; is printing username.. <?php include_once('connect.php'); echo '<pre>'.print_r($_POST, true).'</pre>'; if(isset($_POST["usernamecheck"])){ $username = preg_replace('#[^a-z0-9]#i', '', $_POST['usernamecheck']); echo $username; //// query to check if the username is in the db already //// $unameSQL = $db->prepare("SELECT username FROM members WHERE username=:usernamecheck LIMIT 1"); $unameSQL->bindValue(':usernamecheck',$username,PDO::PARAM_STR); $unameSQL->execute(); // execute the sql $row = $unameSQL->fetch(PDO::FETCH_ASSOC); // fetch the result $count = $unameSQL->rowCount(); // count rows try{ echo 'fired', $row['username']; } catch(PDOException $e){ echo $e->getMessage(); $db = null; exit(); } } //// Check if username is in the db already //// /*if($unCount > 0){ echo "Sorry, that username is already in use in the system"; $db = null; exit(); } else{ echo $uncount; if (strlen($username) < 3 || strlen($username) > 16) { echo '<strong style="color:#F00;">3 - 16 characters please</strong>'; exit(); } if (is_numeric($username[0])) { echo '<strong style="color:#F00;">Usernames must begin with a letter</strong>'; exit(); } if ($unCount < 1) { echo '<strong style="color:#009900;">' . $username . ' is OK</strong>'; exit(); } } }*/ ?>
  14. cabbie

    ajax

    No it doesnt either work I didnt have both files uploaded.
  15. cabbie

    ajax

    Im using onblur so that when you click in the email you get a response..
×
×
  • 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.