Jump to content

Search the Community

Showing results for tags 'mysql'.

  • 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. I have a form, it's reading the mysql database. I have a while loop to display all of the fields in the table so you can edit it. Yes, it displays the fields, but I'm having problems with the update part, when I specify the ID (which is a hidden field) it takes the last field in the form and uses that to update. For example: UPDATE mitigations SET `status`='Watch', `notes`='test6' WHERE id='6';UPDATE mitigations SET `status`='Watch', `notes`='test6' WHERE id='6';UPDATE mitigations SET `status`='Watch', `notes`='test6' WHERE id='6';UPDATE mitigations SET `status`='Watch', `notes`='test6' WHERE id='6';UPDATE mitigations SET `status`='Watch', `notes`='test6' WHERE id='6';UPDATE mitigations SET `status`='Watch', `notes`='test6' WHERE id='6'; I need id to actually get the ID from the form where it's a hidden field. It works now, but only for the last field. Make sense? Here's the actual code I have on the edit form itself: <?php while ($data = mysql_fetch_array($mitigation_query)) {echo "<form><tr><td width='56' height='20px'><input type=hidden name='mitigation_id' value=". $data['id'] ."><span id='MitigationOnTrack'><input type='text' name='mitigation_status' value=". $data['status'] ."></span></td><td width='758'><input type=text name='mitigation_id' value=". $data['id'] ."><textarea rows=5 cols=100 name='mitigation_notes'>" . $data['notes'] ."</textarea></td></tr></form>"; } ?>
  2. is my function of updating medium blobs is correct ??? public function transact_pic_1( $u ) { if ( isset( $_POST[ 'edit' ] ) && $_FILES[ 'pic1' ][ 'size' ] > 0 ) { $pic_1_name = $_FILES[ 'pic1' ][ 'name' ]; $pic_1_tmp_name = $_FILES[ 'pic1' ][ 'tmp_name' ]; $pic_1_file_size = $_FILES[ 'pic1' ][ 'size' ]; $pic_1_file_type = $_FILES[ 'pic1' ][ 'type' ]; $image_date_1 = @date( 'Y-m-d' ); $pic_1_fp = fopen( $pic_1_tmp_name, 'r' ); $pic_1_content = fread( $pic_1_fp, filesize( $pic_1_tmp_name ) ); $pic_1_content = addslashes( $pic_1_content ); fclose( $pic_1_fp ); if ( !get_magic_quotes_gpc() ) { $pic_1_name = addslashes( $pic_1_name ); } //!get_magic_quotes_gpc() if ( $_FILES[ 'pic1' ][ 'error' ] != UPLOAD_ERR_OK ) { switch ( $_FILES[ 'pic1' ][ 'error' ] ) { case UPLOAD_ERR_INI_SIZE: die( 'The uploaded 1st image exceeds the upload_max_filesize directive ' . 'in php.ini.' ); break; case UPLOAD_ERR_FORM_SIZE: die( 'The uploaded 1st exceeds the MAX_FILE_SIZE directive that ' . 'was specified in the HTML form.' ); break; case UPLOAD_ERR_PARTIAL: die( 'The uploaded 1st image was only partially uploaded.' ); break; case UPLOAD_ERR_NO_FILE: die( 'No 1st image was uploaded.' ); break; case UPLOAD_ERR_NO_TMP_DIR: die( 'The server is missing a temporary folder.' ); break; case UPLOAD_ERR_CANT_WRITE: die( 'The server failed to write the uploaded the uploaded 1st image to disk.' ); break; case UPLOAD_ERR_EXTENSION: die( '1st image upload stopped by extension.' ); break; } //$_FILES[ 'pic1' ][ 'error' ] } //$_FILES[ 'pic1' ][ 'error' ] != UPLOAD_ERR_OK $sql = "UPDATE tourDB SET pic_1_name = '$pic_1_name', pic_1_file_size = '$pic_1_file_size', pic_1_file_type = '$pic_1_file_type', pic_1_content = '$pic_1_content', image_date_1 = '$image_date_1' WHERE tour_id = '$tour_id'"; $result = mysql_query( $sql ) or die( mysql_error() ); if ( $result && mysql_affected_rows( $result ) != 0 ) { return true; } //$result && mysql_affected_rows( $result ) != 0 else { return false; } because i cant seem to upload images to this .. i call out the function by this : if ( $_POST[ 'edit' ] ) { $obj->transact_pic_1( $_POST[ 'edit' ] ); } the image is being uploaded but it is not being updated in the coloumn of mediumblob. :/
  3. I am preparing a form form for a new user to register to join a site. I am trying to put some validation in to the user input to ensusre passwords are correct size, and they reverify it etc before it is submitted to the database. I keep getting the same error though when I run the page that I have undefined index. When I actually enter data and hit submit these errors disappear and the appropriate error messages are given to the user. I know its something simple I am forgetting to do but I cannot fathom it out, would someone with more experience be able to point out my error? <?php function user_exists($username){ $server = 'localhost'; $user='root'; $password=''; $db = 'finance_checker'; $mysqli = mysqli_connect($server, $user, $password, $db); if(mysqli_connect_errno($mysqli)){ echo "Failed to connect to MySQL".mysqli_connect_error(); } $res = $mysqli->query("SELECT * FROM `users` WHERE `UserName` = '$username'"); return ($res->num_rows>0); $res->close(); } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Registration</title> <link rel="stylesheet" type="text/css" href="style.css"/> </head> <body> <h1>Registration</h1> <form action="registration.php" method="post"> <ul id="register"> <li> Username : *<br /> <input type ="text" name="username"/> </li> <li> Password : *<br /> <input type ="password" name="password"/> </li> <li> Re-Confirm Password : *<br/> <input type="password" name="password2"/> </li> <li> First Name: *<br /> <input type ="text" name="firstname"/> </li> <li> Last Name : *<br /> <input type ="text" name="lastname"/> </li> <li> Email : *<br /> <input type ="text" name="email"/> </li> <input type="submit" value="Register"/> </ul> </body> </html> <?php if(isset($_POST)){ if(empty($_POST)==false){ $req_fields=array('username','password','password2','firstname','lastname','email'); foreach ($_POST as $key=>$value){ if(empty($value)&& in_array($key, $req_fields)===true){ echo 'Please complete all fields to register!'; break 1; } } } //If there are no errors if(user_exists($_POST['username'])==true){ echo 'Cannot use the username '.$_POST['username'].' it has already been taken!<br />'; } if(preg_match("/\\s/", $_POST['username'])){ echo "Your username must not contain any spaces!"; } //Make sure the password is of sufficient length if((strlen($_POST['password']<6))||(strlen($_POST['password']>12))){ echo 'Password must be at least 6 characters long and no more than 12.<br />'; } if($_POST['password']!=$_POST['password2']){ echo 'Passwords do not match. Please try again! <br />'; } if(!(filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))){ echo 'Email address is not valid.Please enter a valid email address'; } } ?>
  4. Hi people. I'm creating a website that runs on php and mysql. I have a list page which grabs all the info on mysql and displays the content. once clicking on one of these it brings up a single page which lists more info on that specific item. what I want is to add a comments field(feedback / review or what ever you may wish to call it) underneath the info on the single page. The commenter does not need to be logged in but maybe use there facebook Id or something to stop spammers clogging up the page. what is the best way to do this? Will it be using another mysql field called review? or is there some other way of doing this? please can someone point me in the right direction for a tutorial (youtube preferably)? thanks for your help. Kev.
  5. I'm working on a project that users can enter their name to complete a multiple choice quiz, while administrators can log in to add new questions and edit and delete existing questions. I've created a multiple choice quiz in PHP and MySQL that loops questions on the same page, instead of multiple pages. Basically, you click on the submit button to go to the next set of questions, but on the same page. The questions are data retrieved from a database I created in PhpMyAdmin. The problem now is I have no idea what code to refer to when trying to calculate answers in the final results page, so I was wondering if someone could help me out. Underneath is the code I have for my quiz.php page, and now I want to calculate how many questions I have answered correctly. I'd really appreciate the help. <?php //CODE FOR QUIZ.PHP //Code retrieves the name that the user typed in the text-field. session_start(); require 'includes/connection.php'; $name = $_REQUEST['name']; $_SESSION['name'] = $name; //User's name is displayed above the quiz. echo 'Welcome, '.$name; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>World War II Quiz</title> </head> <body> <?php //Start with question ID if (isset($_GET['id'])) { //get question id from user and store $question_id = $_GET['id']; } else { $question_id = 1; //no question id submitted //unset session data unset($_SESSION['questions']); unset($_SESSION['total']); } //If the questions array has been built if (isset($_SESSION['questions'])) { //has the user selected a radio button if (isset($_REQUEST['value'])) { //check for correct if ($_SESSION['answer'] == $_REQUEST['value']) { //correct answer $_SESSION['total']++; } } else { //No value inputted from the user echo "hey bozo click a button"; $question_id--; } } //Questions array is not been built else { //get a list of question id's $sql = "SELECT question_id FROM questions ORDER BY question_id ASC"; $results = mysql_query($sql,$conn); $stringtemp = ""; $maxtemp = 1; while ($row = mysql_fetch_assoc($results)) //More results { $stringtemp = $stringtemp." ".$row['question_id']; $maxtemp++; } //Create question id array pulled from database $_SESSION['questions'] = explode(" ",$stringtemp); //Max value of the array $_SESSION['max']=$maxtemp; } $sql = "select * from questions where question_id =".$_SESSION['questions'][$question_id]; $results = mysql_query($sql,$conn); $row = mysql_fetch_array($results); //Store correct answer for next pageload $_SESSION['answer'] = $row['correct']; $nextid=$question_id+1; if ($nextid == $_SESSION['max']) { //Final question $next = "results.php"; } else { $_SESSION['name'] = $name; //Not the final question $next = "quiz.php?id=".$nextid; } echo "<form action=\"".$next."\" method=\"post\" name=\"form\" > <p>".$row['question_text']."</p> <input type=\"radio\" name=\"value\" value=\"1\">".$row['answer1']."<br> <input type=\"radio\" name=\"value\" value=\"2\">".$row['answer2']."<br> <input type=\"radio\" name=\"value\" value=\"3\">".$row['answer3']."<br> <input type=\"radio\" name=\"value\" value=\"4\">".$row['answer4']."<br> <input class=\"submit\" type=\"submit\" value=\"Submit\"/> </form> </body> </html> "; ?>
  6. Here is the code for both the connection file and the main body of script. I assure you the passwords and actual names do match as I have done other tests before hand. register.php <?php $title = "Register"; include 'includes/header.php'; if($_SERVER['REQUEST_METHOD'] == 'POST') { require 'includes/connection.php'; //create FALSE figures $username = $password = FALSE; //trim all data $trimmed = array_map('trim', $_POST); $errors = array(); //check username if(preg_match ('/[A-Za-z0-9]{2,20}/', $trimmed['username'])) { $username = mysqli_real_escape_string($dbc, $trimmed['username']); } else { $errors[] = 'Enter a username'; } //check password if(preg_match ('/[A-Za-z0-9]{4,20}/', $trimmed['password'])) { $username = mysqli_real_escape_string($dbc, $trimmed['password']); } else { $errors[] = 'Enter a password'; } //variables not == FALSE if($username && $password) { $q = "SELECT user_id FROM users WHERE username='$username'"; $r = mysqli_query ($dbc, $q) OR trigger_error("Query: $q\n<br />MYSQL Error: ". mysql_error($dbc)); if(mysqli_num_rows($r) == 0) { $q = "INSERT INTO users (username, password, registration_date) VALUES ('$username', SHA1('$password'), NOW() )"; $r = mysqli_query ($dbc, $q) OR trigger_error("Query: $q\n<br />MYSQL Error: ". mysql_error($dbc)); } if(mysqli_affected_rows($dbc) == 1) { echo "success"; //header('Location: database.php'); } } else { foreach ($errors as $msg) { echo " - $msg<br />\n"; } } } ?> <form action="register.php" method="POST"> <input type="text" name="username" value="<?php if(isset($trimmed['username'])) echo $trimmed['username']; ?>" placeholder="Username"/> <input type="password" name="password" value="<?php if(isset($trimmed['username'])) echo $trimmed['password']; ?>" placeholder="Password"/> <input type="submit" class="button1" name="Sign Up" /> </form> connection.php <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'password'; $db = 'ze'; $dbc = mysqli_connect($dbhost, $dbuser, $dbpass) OR die ('Could not connect. MYSQL:' .mysql_error() ); mysql_select_db($db); Whenever I run this it does not seem to want to work, and also outputs no errors. I probably cant see something and need a second opinion.
  7. Hello, I'm attempting to assemble a larger JOIN query using a SubSelect, but have realized my standalone SubSelect is not returning what I seek. Query (this is to be my SubSelect): SELECT s.primary_id, s.user_id, MAX(s.date) AS c_date, s.tradeshow_id FROM comments AS s GROUP BY s.tradeshow_id This table houses comments for another table, and tracks a user_id and which tradeshow (is being commented on) Example (primary_id is unique for each row, user_id & tradeshow_id are repeatable, wanting to sort by date, returning latest row PER tradeshow_id primary_id user_id tradeshow_id date 1 1 11 2013-10-19 13:51:55 2 1 11 2013-10-04 09:21:30 3 5 11 2013-06-20 10:24:25 4 1 11 2013-04-23 14:12:19 5 5 11 2013-10-20 11:14:35 6 1 13 2013-08-14 08:24:54 7 5 13 2013-08-17 15:45:15 8 5 13 2013-09-05 09:42:09 9 5 13 2013-06-26 12:13:27 10 1 2 2013-10-12 13:28:04 When looking at my results, for tradeshow 11 for example, the result the proper "MAX" date (2013-10-20), but in the same row, shows the primary_id of 1. I, of course, want the row to stay linked. Assistance would by greatly appreciated. I am stuck. Thank you, Adam
  8. Hello 2 tables - users (userid, username) - friends (friendshipid, user1, user2, accepted) I have a friends search box (works like google's/facebook's auto suggest). This search box is meant to be used to pick a friend to send a private message to. So far, all my code can do is autosuggest people on the social network (basically display all people on the users table based on the characters typed). <?php mysql_connect("localhost","username","pass"); mysql_select_db("dbname"); $term=$_GET["term"]; $query=mysql_query("SELECT userid, username FROM users where username like '%".$term."%'"); $json=array(); while($friend=mysql_fetch_array($query)){ $json[]=array( 'value'=> $friend["username"] ); } echo json_encode($json); ?> I wanted it to filter out those who are not friends. BTW, just to clarify, the logged in user who wants to send a private message, his userid could be on either user1/user2 of the friends table. Any idea behind the logic that could sort this issue? Will really appreciate any help
  9. continuing discussion from http://forums.phpfreaks.com/topic/283080-cant-update-my-tables/ I was making a programme on updating the values of the database, here is the file where post is made. edit.php $con=mysql_connect("127.0.0.1","username","password"); mysql_select_db("database") or die( "Could not select database. " . mysql_error() ); // Check connection $_GET['id'] = $id; if ( $_POST['tour_id'] ) $tour_id = mysql_real_escape_string( $_POST['tour_id']); if ( $_POST[ 'tour_name' ] ) $tour_name = mysql_real_escape_string( $_POST[ 'tour_name' ] ); if ( $_POST[ 'tour_type' ] ) $tour_type = mysql_real_escape_string( $_POST[ 'tour_type' ] ); if ( $_POST[ 'day' ] ) $day = mysql_real_escape_string( $_POST[ 'day' ] ); if ( $_POST[ 'nights' ] ) $nights = mysql_real_escape_string( $_POST[ 'nights' ] ); if ( $_POST[ 'twin_triple_sharing' ] ) $twin_triple_sharing = mysql_real_escape_string( $_POST[ 'twin_triple_sharing' ] ); if ( $_POST[ 'overview' ] ) $overview = mysql_real_escape_string( $_POST[ 'overview' ] ); if ( $_POST[ 'itinerary' ] ) $itinerary = mysql_real_escape_string( $_POST[ 'itinerary' ] ); if ( $_POST[ 'inclusions' ] ) $inclusions = mysql_real_escape_string( $_POST[ 'inclusions' ] ); if ( $_POST[ 'exclusions' ] ) $exclusions = mysql_real_escape_string( $_POST[ 'exclusions' ] ); if ( $_POST[ 'single_occcupancy' ] ) $single_occcupancy = mysql_real_escape_string( $_POST[ 'single_occcupancy' ] ); if ( $_POST[ 'child_with_no_bed' ] ) $child_with_no_bed = mysql_real_escape_string( $_POST[ 'child_with_no_bed' ] ); if ( $_POST[ 'inf_below' ] ) $inf_below = mysql_real_escape_string( $_POST[ 'inf_below' ] ); if ( $_POST[ 'keywords' ] ) $keywords = mysql_real_escape_string( $_POST[ 'keywords' ] ); if ( $_POST[ 'title' ] ) $title = mysql_real_escape_string( $_POST[ 'title' ] ); if ( $_POST[ 'description' ] ) $description = mysql_real_escape_string( $_POST[ 'description' ] ); if ( $_POST[ 'url' ] ) $url = mysql_real_escape_string( $_POST[ 'url' ] ); if ( $_POST[ 'categories' ] ) $categories = mysql_real_escape_string( $_POST[ 'categories' ] ); if ( $_POST[ 'alt1' ] ) $image_alt_1 = mysql_real_escape_string( $_POST[ 'alt1' ] ); if ( $_POST[ 'alt2' ] ) $image_alt_2 = mysql_real_escape_string( $_POST[ 'alt2' ] ); if ( $_POST[ 'alt3' ] ) $image_alt_3 = mysql_real_escape_string( $_POST[ 'alt3' ] ); if ( $_POST[ 'alt4' ] ) $image_alt_4 = mysql_real_escape_string( $_POST[ 'alt4' ] ); if ( $_POST[ 'alt5' ] ) $image_alt_5 = mysql_real_escape_string( $_POST[ 'alt5' ] ); if ( $_POST['tour_id'] ) $tour_id = mysql_real_escape_string( $_POST['tour_id']); if ( $_POST[ 'tour_name' ] ) $tour_name = mysql_real_escape_string( $_POST[ 'tour_name' ] ); if ( $_POST[ 'tour_type' ] ) $tour_type = mysql_real_escape_string( $_POST[ 'tour_type' ] ); if ( $_POST[ 'day' ] ) $day = mysql_real_escape_string( $_POST[ 'day' ] ); if ( $_POST[ 'nights' ] ) $nights = mysql_real_escape_string( $_POST[ 'nights' ] ); if ( $_POST[ 'twin_triple_sharing' ] ) $twin_triple_sharing = mysql_real_escape_string( $_POST[ 'twin_triple_sharing' ] ); if ( $_POST[ 'overview' ] ) $overview = mysql_real_escape_string( $_POST[ 'overview' ] ); if ( $_POST[ 'itinerary' ] ) $itinerary = mysql_real_escape_string( $_POST[ 'itinerary' ] ); if ( $_POST[ 'inclusions' ] ) $inclusions = mysql_real_escape_string( $_POST[ 'inclusions' ] ); if ( $_POST[ 'exclusions' ] ) $exclusions = mysql_real_escape_string( $_POST[ 'exclusions' ] ); if ( $_POST[ 'single_occcupancy' ] ) $single_occcupancy = mysql_real_escape_string( $_POST[ 'single_occcupancy' ] ); if ( $_POST[ 'child_with_no_bed' ] ) $child_with_no_bed = mysql_real_escape_string( $_POST[ 'child_with_no_bed' ] ); if ( $_POST[ 'inf_below' ] ) $inf_below = mysql_real_escape_string( $_POST[ 'inf_below' ] ); if ( $_POST[ 'keywords' ] ) $keywords = mysql_real_escape_string( $_POST[ 'keywords' ] ); if ( $_POST[ 'title' ] ) $title = mysql_real_escape_string( $_POST[ 'title' ] ); if ( $_POST[ 'description' ] ) $description = mysql_real_escape_string( $_POST[ 'description' ] ); if ( $_POST[ 'url' ] ) $url = mysql_real_escape_string( $_POST[ 'url' ] ); if ( $_POST[ 'categories' ] ) $categories = mysql_real_escape_string( $_POST[ 'categories' ] ); if ( $_POST[ 'alt1' ] ) $image_alt_1 = mysql_real_escape_string( $_POST[ 'alt1' ] ); if ( $_POST[ 'alt2' ] ) $image_alt_2 = mysql_real_escape_string( $_POST[ 'alt2' ] ); if ( $_POST[ 'alt3' ] ) $image_alt_3 = mysql_real_escape_string( $_POST[ 'alt3' ] ); if ( $_POST[ 'alt4' ] ) $image_alt_4 = mysql_real_escape_string( $_POST[ 'alt4' ] ); if ( $_POST[ 'alt5' ] ) $image_alt_5 = mysql_real_escape_string( $_POST[ 'alt5' ] ); $sql = "UPDATE tourDB SET tour_name = '$tour_name', tour_type = '$tour_type', nights = '$nights', overview = '$overview', itinerary = '$itinerary', inclusions = '$exclusions', twin_triple_sharing = '$single_occcupancy', child_with_no_bed = '$child_with_no_bed', inf_below = '$inf_below', keywords = '$keywords', title = '$title', description = '$description', url = '$url', categories = '$categories' WHERE tour_id = '$id'"; return mysql_query( $sql ) or die( mysql_error() ); mysql_query($con, $sql); mysql_close($con); i havent wrote the full values, the mysql query yet but it will do for checking, i hope...? here is the form, (left out most the javascript, and jquery etc....) <?php $id = $_GET[ 'id' ]; $q = "SELECT * FROM tourDB WHERE tour_id = '$id' "; $r = mysql_query( $q ); if ( $r !== false && mysql_num_rows( $r ) > 0 ) { while ( $mfa = mysql_fetch_assoc( $r ) ) { $tour_id = stripslashes( $mfa[ 'tour_id' ] ); $tour_type = stripslashes( $mfa[ 'tour_type' ] ); $tour_name = stripslashes( $mfa[ 'tour_name' ] ); $day = stripslashes( $mfa[ 'day' ] ); $nights = stripslashes( $mfa[ 'nights' ] ); $tour_price = stripslashes( $mfa[ 'tour_price' ] ); $overview = stripslashes( $mfa[ 'overview' ] ); $itinerary = stripslashes( $mfa[ 'itinerary' ] ); $terms_conditons = stripslashes( $mfa[ 'terms_conditons' ] ); $inclusions = stripslashes( $mfa[ 'inclusions' ] ); $exclusions = stripslashes( $mfa[ 'exclusions' ] ); $twin_triple_sharing = stripslashes( $mfa[ 'twin_triple_sharing' ] ); $single_occcupancy = stripslashes( $mfa[ 'single_occcupancy' ] ); $child_with_no_bed = stripslashes( $mfa[ 'child_with_no_bed' ] ); $inf_below = stripslashes( $mfa[ 'inf_below' ] ); $pricing_details = stripslashes( $mfa[ 'pricing_details' ] ); $url = stripslashes( $mfa[ 'url' ] ); $keywords = stripslashes( $mfa['keywords']); $title = stripslashes( $mfa['title']); $description = stripslashes( $mfa['description']); $categories = stripslashes( $mfa['categories']); $image_alt_1 = stripslashes( $mfa['image_alt_1']); $image_alt_2 = stripslashes( $mfa['image_alt_2']); $image_alt_3 = stripslashes( $mfa['image_alt_3']); $image_alt_4 = stripslashes( $mfa['image_alt_4']); $image_alt_5 = stripslashes( $mfa['image_alt_5']); $pic_1_name = stripslashes( $mfa['pic_1_name']); $pic_2_name = stripslashes( $mfa['pic_2_name']); $pic_3_name = stripslashes( $mfa['pic_3_name']); $pic_4_name = stripslashes( $mfa['pic_4_name']); $pic_5_name = stripslashes( $mfa['pic_5_name']); $pic_1_file_size = stripslashes( $mfa['pic_1_file_size']); $pic_2_file_size = stripslashes( $mfa['pic_2_file_size']); $pic_3_file_size = stripslashes( $mfa['pic_3_file_size']); $pic_4_file_size = stripslashes( $mfa['pic_4_file_size']); $pic_5_file_size = stripslashes( $mfa['pic_5_file_size']); $pic_1_file_type = stripslashes( $mfa['pic_1_file_type']); $pic_2_file_type = stripslashes( $mfa['pic_2_file_type']); $pic_3_file_type = stripslashes( $mfa['pic_3_file_type']); $pic_4_file_type = stripslashes( $mfa['pic_4_file_type']); $pic_5_file_type = stripslashes( $mfa['pic_5_file_type']); $image_date_1 = stripslashes( $mfa['image_date_1']); $image_date_2 = stripslashes( $mfa['image_date_2']); $image_date_3 = stripslashes( $mfa['image_date_3']); $image_date_4 = stripslashes( $mfa['image_date_4']); $image_date_5 = stripslashes( $mfa['image_date_5']); if ( $tour_type == 'international' ) { $option1 = 'checked="checked"'; } //$tour_type == 'international' elseif ( $tour_type == 'domestic' ) { $option2 = 'checked="checked"'; } //$tour_type == 'domestic' elseif ( $tour_type == 'insta_deals' ) { $option3 = 'checked="checked"'; } //$tour_type == 'insta_deals' else { $option = 'checked="checked"'; } $edit_package = <<<EDIT_PACKAGE <form action="edit.php?id=$id" method="post" enctype="multipart/form-data"> <script type="text/javascript" > $(function new_editor() { $('#transportation_$tour_id').wysiwyg({ autoGrow: true, initialContent: "<p>Transportation Content</p>", maxHeight: 600 }); $('#payment-norms_$tour_id').wysiwyg({ autoGrow: true, initialContent: "<p>Payment Content</p>", maxHeight: 600 }); $('#overview_$tour_id').wysiwyg({ autoGrow: true, initialContent: "$overview", maxHeight: 600 }); $('#inclusions_$tour_id').wysiwyg({ autoGrow: true, initialContent: "$inclusions", maxHeight: 600 }); $('#exclusions_$tour_id').wysiwyg({ autoGrow: true, initialContent: "$exclusions", maxHeight: 600 }); $('#itinerary_$tour_id').wysiwyg({ autoGrow: true, initialContent: "$itinerary", maxHeight: 600 }); $('#pricing_details_$tour_id').wysiwyg({ autoGrow: true, initialContent: "$pricing_details", maxHeight: 600 }); }); </script> <div id="tour-package" > <ul> <li><a href="#genral">General Information</a></li> <li><a href="#picture">Picture And Meta Info</a></li> <li><a href="#tour-inclusions">Tour Inclusions</a></li> <li><a href="#tour-feature">Itinerary</a></li> <!--<li><a href="#availibility">Availability and Others</a></li>--> <li><a href="#billing">Billing And Prices</a></li> </ul> <div id="genral"> <input type="hidden" name="tour_id" value="$id" /> <div class="package-element"> <p><span class="left" >Tour Name: <input type="text" name="tour_name" value= "$tour_name" id="tour_name" /></span></p> </div> <div class="package-element"> <p>Tour Type: <select id="tour_type" name="tour_type" > <option value="null-category" $option >Select Tour Type</option> <option value="international" $option1 >International Tours</option> <option value="domestic" $option2 > Domestic Tours </option> <option value="insta_deals" $option3 >Insta Deals</option> </select> </p> </div> <div class="package-element"> <p>No. of Days: <input type="text" size="2" id="day" value="$day" name="day" /> </p> </div> <div class="package-element"> <p> No. of Nights: <input type="text" name="nights" value="$nights" id="nights" size="2" /> </p> </div> <div class="package-element" > <p> Sub categories <input type="text" name="categories" value="$categories" id="categories" size="5" /> </p> </div> <div class="package-element"> <div class="package-element-head"> <p>Overview of the package :</p> </div> <br /> <div class="package-element"> <textarea rows="10" cols="70" value="" id="overview_$tour_id" name="overview" ></textarea> </div> </div> <div class="cleaner"></div><br /> </div> <div id="picture" > <div class="chavi" > <div class="package-element-head" > <p>Pictures To upload (.jpg, .png) :</p> </div> <div class="cleaner"></div> <div class="chavi-element" > <span class="left"> 1st Image </span> <span class="left"><input type="file" accept ="image/gif, image/jpeg" name="pic1" id="pic1" /></span> <span class="right" ><input value="$image_alt_1" id="alt1" name="alt1" type="text" size="20" /> </span><span class="right">Alt of 1st image </span> </div> <div class="chavi-element" > <span class="left">2nd Image </span> <span class="left"><input type="file" accept ="image/gif, image/jpeg" name="pic2" id="pic2" /></span> <span class="right"><input value="$image_alt_2" name="alt2" id="alt2" type="text size="20" /></span> <span class="right">Alt of 2nd image </span> </div> <div class="chavi-element"> <span class="left" > 3rd Image</span> <span class="left"><input type="file" accept ="image/gif, image/jpeg" name="pic3" id="pic3" /></span> <span class="right" ><input value="$image_alt_3" name="alt3" id="alt3" type="text" size="20" /></span> <span class="right" >Alt of 3rd image </span> </div> <div class="chavi-element" > <span class="left" >4th Image</span> <span class="left"><input type="file" accept ="image/gif, image/jpeg" name="pic4" id="pic4" /></span> <span class="right"><input name="alt4" value="$image_alt_4" id="alt4" type="text" size="20" /></span> <span class="right">Alt of 4th image </span> </div> <div class="chavi-element" > <span class="left" >5th Image</span> <span class="left"><input type="file" accept ="image/gif, image/jpeg" name="pic5" id="pic5" /></span> <span class="right"><input type="text" value="$image_alt_5" name="alt5" id="alt5" size="20" /></span> <span class="right">Alt of 5th image </span> </div> </div> <div class="meta-info"> <div class="package-element-head" > <p>Title:</p> </div> <div class="package-element" > <input type="text" value="$title" size="30" id="title" name="title" /> </div> <div class="package-element-head-2" > Keywords: </div> <div class="package-element" > <textarea rows="5" value="$keywords" cols="28" id="keywords" name="keywords" >$keywords</textarea> </div> </div> <div class="meta-info" > <div class="package-element-head" > Description: </div> <div class="package-element" > <textarea rows="5" cols="30" value="$description" name="description" id="description">$description</textarea> </div> <div class="package-element-head-2" > URL of the page: </div> <div class="package-element" > <input type="text" size="30" value="$url" name="url" id="url" onblur="this.value=removeSpaces(this.value);" /> </div> </div> <div class="cleaner"></div> </div> <div id="tour-inclusions"> <div class="inclusions-exclusions"> <div class="package-element-head" > Inclusions: </div> <div class="package-element" > <textarea rows="10" cols="70" name="inclusions" id="inclusions_$tour_id"></textarea> </div> </div> <div class="inclusions-exclusions"> <div class="package-element-head" > Exlcusions: </div> <div class="package-element"> <textarea rows="10" cols=70" name="exclusions" id="exclusions_$tour_id"></textarea> </div> </div> <div class="cleaner"></div> </div> <div id="tour-feature"> <div class="package-element-head"> Itinerary: </div> <div class="package-element" > <textarea rows="30" cols="75" name="itinerary" id="itinerary_$tour_id"></textarea> </div> <div class="cleaner"></div> </div> <div id="billing"> <div class="price-tab" > <div class="price-tab-row" > <div class="price-tab-element"> <b>Pax Type</b> </div> <div class="price-tab-element"> <b>Tour Price Total in INR</b> </div> </div> <div class="price-tab-row" > <div class="price-tab-element" > Twin/Triple Sharing </div> <div class="price-tab-element" > <span class="rupee">`</span> <input typ="text" value="$twin_triple_sharing" size="7" name="twin_triple_sharing" id="twin_triple_sharing" /> </div> </div> <div class="price-tab-row" > <div class="price-tab-element" > Single Occupancy </div> <div class="price-tab-element" > <span class="rupee">`</span> <input type="text" size="7" name="single_occcupancy" id="single_occcupancy" value=" $single_occcupancy "/> </div> </div> <div class="price-tab-row"> <div class="price-tab-element" > Child With No Bed </div> <div class="price-tab-element"> <span class="rupee" >`</span> <input type="text" size="7" value="$child_with_no_bed" name="child_with_no_bed" id="child_with_no_bed" /> </div> </div> <div class="price-tab-row"> <div class="price-tab-element"> Infant below 2 years </div> <div class="price-tab-element" > <span class="rupee" >`</span> <input type="text" value="$inf_below" size="7" name="inf_below" id="inf_below" /> </div> </div> <div class="package-element-head-2">Terms And Conditions:</div> <div class="cleaner"></div> <div class="package-element" > <textarea rows="10" cols="70" value="$terms_conditions" id="pricing_details_$tour_id" name="terms_conditions" ></textarea> </div> <input type="submit" name="submit" id="submit" value="Create This Entry!" /> <div class="cleaner" ></div> </div> </div> </div> </form> <br /> </div> EDIT_PACKAGE; } //$mfa = mysql_fetch_assoc( $r ) } //$r !== false && mysql_num_rows( $r ) > 0 else { $edit_package = <<<EDIT_PACKAGE <div class="domestic-tours"> <ul> <li><a href="#notice">Notice</a></li> </ul> <div id="notice" > <h2> The tour does not exist </h2> </div> <div class="cleaner" ></div> </div> EDIT_PACKAGE; } echo $edit_package; ?> The whole script is bit big so, if needed i will attach the files ... some of it are in functions within a class...
  10. Could some one tell me how to use session variable across multiple domain. For example I have created a project in open cart. Need to pass the sessiion variables once user logged in same to another domain www.domain1.com www.subdomain1.com How to achieve this. please someone help me to do this using php
  11. Hello all, I have created a database with 2 tables table1 and table2 like this (except desc, all columns are integer type and the leftmost column is always the primary key): table1: pid desc ================ 1001 Apple 1002 Orange 1003 Papaya table2: key pid cat ===================== 10001 1001 101 10002 1001 102 10003 1002 101 10004 1003 102 In other words, item 1001 (Apple) belongs to categories 101 and 102, while item 1002 (Orange) belongs to cat 101 only, and item 1003 (Papaya) belongs to cat 102 only. Now I would like to make a SELECT statement that returns the name of the item(s) that belong to both categories 101 and 102 (in the above case, Apple). Any simple way (using as few statements as possible) to do this? Thanks! -- Pengi.
  12. Hey, I would like to import data from CSV files to my application, First i've upload csv on to server then get csv contents by fgetcsv(), after that i want to map uploaded data and validate then send to db otherwise show error. Please suggest me how to do. Thanks
  13. why I am getting this error ??? Warning: Missing argument 1 for manage::new_package(), called in /home/content/52/11446152/html/excitetrips/session/admin-logged.php on line 214 and defined in/home/content/52/11446152/html/excitetrips/session/core/core-management.php on line 1245 this is script i was working on... admin-logged.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="language" content="en" /> <link rel="apple-touch-icon-precomposed" href="../img/logo.png" /> <meta name="viewport" content="width=400, initial-scale=1.0" /> <title>Excite trips , your best travel trips</title> <link rel="shortcut icon" type="image/x-icon" href="../img/favicon.ico" /> <link rel="stylesheet" type="text/css" href="css/bjqs.css" /> <link rel="stylesheet" type="text/css" media="only screen and (max-device-width: 990px)" href="css/mobile.css" /> <link rel="stylsheet" type="text/css" media="print" href="../css/print.css" /> <link rel="stylesheet" type="text/css" href="../css/jquery-ui-1.10.3.custom.css" /> <link href="../style.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" href="../css/jquery.wysiwyg.css" type="text/css"/> <script type="text/javascript" src="js/mobile-redirection-2.js" ></script> <script type="text/javascript" src="../js/jquery-1.9.1.js"></script> <script type="text/javascript" src="../js/bjqs-1.3.js"></script> <script type="text/javascript" src="../js/jquery-ui-1.10.3.custom.js"></script> <script type="text/javascript" src="../js/jquery.validate.js" ></script> <script type="text/javascript" src="../js/jquery.wysiwyg.js"></script> <script type="text/javascript" src="../js/wysiwyg.image.js"></script> <script type="text/javascript" src="../js/wysiwyg.link.js"></script> <script type="text/javascript" src="../js/wysiwyg.table.js"></script> <script type="text/javascript"> $(function domestic_boxes(){ $('.domestic-tours').tabs(); /* $('#book-now').button(); $('#call').button(); */ $('#submit').button(); }); $(function icons(){ // Hover states on the static widgets $( "#dialog-link, #icons li" ).hover( function() { $( this ).addClass( "ui-state-hover" ); }, function() { $( this ).removeClass( "ui-state-hover" ); } ); }); $(function icon() { // hover states on static images $( "#dialog-link, #icons li" ).hover( function() { $( this ).addClass( "ui-state-hover" ); }, function() { $( this ).removeClass( "ui-state-hover" ); } ); }); $(function TourInput(){ $('#tour-package').tabs(); $('#days').keyup(function pickdays() { if (this.value != this.value.replace(/[^0-9\.]/g, '')) { this.value = this.value.replace(/[^0-9\.]/g, ''); } }); $('#nights').keyup(function picknights() { if (this.value != this.value.replace(/[^0-9\.]/g, '')) { this.value = this.value.replace(/[^0-9\.]/g, ''); } }); $('#twin_triple_shareing').keyup(function picknights() { if (this.value != this.value.replace(/[^0-9\.]/g, '')) { this.value = this.value.replace(/[^0-9\.]/g, ''); } }); $('#single_occupancy').keyup(function picknights() { if (this.value != this.value.replace(/[^0-9\.]/g, '')) { this.value = this.value.replace(/[^0-9\.]/g, ''); } }); $('#child_no_bed').keyup(function picknights() { if (this.value != this.value.replace(/[^0-9\.]/g, '')) { this.value = this.value.replace(/[^0-9\.]/g, ''); } }); $('#infbelow').keyup(function picknights() { if (this.value != this.value.replace(/[^0-9\.]/g, '')) { this.value = this.value.replace(/[^0-9\.]/g, ''); } }); /* $('#transportation').wysiwyg({ autoGrow: true, maxHeight: 600 }); $('#payment-norms').wysiwyg({ autoGrow: true, maxHeight: 600 }); $('#overview').wysiwyg({ autoGrow: true, maxHeight: 600 }); $('#inclusions').wysiwyg({ autoGrow: true, maxHeight: 600 }); $('#exclusions').wysiwyg({ autoGrow: true, maxHeight: 600 }); $('#itinerary').wysiwyg({ autoGrow: true, maxHeight: 600 }); $('#pricingdetails').wysiwyg({ autoGrow: true, maxHeight: 600 }); */ }); </script> <script type="text/javascript"> function removeSpaces(string) { return string.split(' ').join(''); } </script> </head> <body> <!--Header End --> <div id="header"> <div class="header-top"> <div class="head-left"><a href="index.html" ><img alt="Car hire Kolkata" src="../img/site-logo.png" /></a></div> <div class="contact"><div class="head-left"><img height="50" width="55" alt="telephone" src="../img/telephone.png" /></div><div class="head-right">+919830042523</div></div> <div class="contact"><div class="head-left"><img height="50" width="55" alt="email" src="../img/email.png" /></div><div class="head-right">support@excitetrips.com</div></div> </div> <div class="cleaner"></div> <div class="navbar"> <ul class="nav"> <li><a href="admin-logged.php"><strong>Dashboard</strong></a></li> <li><a href="admin-logged.php?tour_type=international"><strong>International</strong></a></li> <li><a href="admin-logged.php?tour_type=domestic"><strong>Domestic</strong></a></li> <li><a href="admin-logged.php?tour_type=insta_deals"><strong>Insta Deals</strong> </a></li> <li><a href="#"><strong>Add Package</strong> </a></li> <li><a href="insta-deals.html"><strong>Log Out</strong> </a></li> </ul> </div> </div> <!--Header End --> <!--Container --> <div id="container"> <div class="cleaner"></div> <div class="package-part-left" > <div class="domestic-tour-lists"> <?php include_once( 'core/core-management.php' ); $tour_type = $_GET['tour_type']; $package_edit = $_GET['package_edit']; $manage = new manage(); /* SETTINGS FOR DATABASE */ $manage->manage_host = 'localhost'; $manage->manage_username = 'username'; $manage->manage_password = 'pass'; $manage->manage_table = 'table'; $manage->connect_core(); if (isset($update)) { $manage->update_pic_1( $_POST ); $manage->update_pic_2( $_POST ); $manage->update_pic_3( $_POST ); $manage->update_pic_4( $_POST ); $manage->update_pic_5( $_POST ); $manage->update_text( $_POST ); } /* if ( $_POST ) { printf('<pre>POST %s</pre>', print_r($_POST, true)); echo 'post initiated !!'; $manage->write( $_POST ); } if ( $_SERVER['REQUEST_METHOD'] == 'POST') { echo 'Request initiated for post !';} if($manage->write($_POST) === false) { echo 'Sorry, no data added to database'; } else { echo 'data has been added to database'; } */ if ( isset($tour_type)) { switch ($tour_type) { case "international": echo $manage->packages_international(); continue; case "domestic": echo $manage->packages_domestic(); continue; case "insta_deals": echo $manage->packages_insta_deals(); continue; default: echo 'internal error !! stop messing with my url !!!'; } }elseif(isset($package_edit)) { switch ($package_edit) { case "new_package": echo $manage->new_package($new_package); break; case "edit_package": echo $manage->edit_package(); break; case "delete_package": echo $manage->delete_package(); break; } } else { echo $manage->display_all(); } ?> and the core-management.php is attached to this post core-management.php
  14. I have this bellow code its a jquery to add form elements dynamically. my question is when Im submiting the form to the database it only send first set of elements value only, rest are not sending to the database, plz help me on this.. here is my codes. jquery- <script type="text/Javascript"> $(document).ready(function() { $('#btnAdd').click(function() { var num = $('.clonedSection').length; var newNum = new Number(num + 1); var newSection = $('#pq_entry_' + num).clone().attr('id', 'pq_entry_' + newNum); newSection.children(':first').children(':first').attr('id', 'contNo_' + newNum).attr('name', 'contNo_' + newNum); newSection.children(':nth-child(2)').children(':first').attr('id', 'contNo2_' + newNum).attr('name', 'contNo2_' + newNum); newSection.children(':nth-child(3)').children(':first').attr('id', 'contNo3_' + newNum).attr('name', 'contNo3_' + newNum); newSection.children(':nth-child(4)').children(':first').attr('id', 'contNo4_' + newNum).attr('name', 'contNo4_' + newNum); newSection.children(':nth-child(5)').children(':first').attr('id', 'contNo5_' + newNum).attr('name', 'contNo5_' + newNum); newSection.children(':nth-child(6)').children(':first').attr('id', 'contNo6_' + newNum).attr('name', 'contNo6_' + newNum); newSection.insertAfter('#pq_entry_' + num).last(); $('#btnDel').prop('disabled',''); if (newNum == 5) $('#btnAdd').prop('disabled','disabled'); }); $('#btnDel').click(function() { var num = $('.clonedSection').length; // how many "duplicatable" input fields we currently have $('#pq_entry_' + num).remove(); // remove the last element // enable the "add" button $('#btnAdd').prop('disabled',''); // if only one element remains, disable the "remove" button if (num-1 == 1) $('#btnDel').prop('disabled','disabled'); }); $('#btnDel').prop('disabled','disabled'); }); //$('#blinfo').on('submit', function (e) { //prevent the default submithandling // e.preventDefault(); //send the data of 'this' (the matched form) to yourURL // $.post('bladd.php', $(this).serialize()); //}); </script> Here is the HTML (both codes are in the same file) <ul id="pq_entry_1" class="clonedSection"> <li><input type="text" name="contNo_1" id="contNo_1" size="45" value=""/></li> <li>SIZE<input type="text" name="contNo2_1" id="contNo2_1" size="15" value=""/></li> <li>MODE<input type="text" name="contNo3_1" id="contNo3_1" size="15" value=""/></li> <li>PICES<input type="text" name="contNo4_1" id="contNo4_1" size="15" value=""/></li> <li>WEIGHT<input type="text" name="contNo5_1" id="contNo5_1" size="15" value=""/></li> <li>VOLUME<input type="text" name="contNo6_1" id="contNo6_1" size="15" value=""/></li> </ul> <input type='button' id='btnAdd' size="15" value='add another row' /><input type='button' id='btnDel' value='delete row' /> and here is my sql query <?php $con=mysqli_connect("localhost","root","1234","shipping"); // Check connection if (mysqli_connect_errno()) { mysqli_connect_error(); } $sql="INSERT INTO infobl (contNo_1, contNo2_1, contNo3_1, contNo4_1, contNo5_1, contNo6_1, contNo_2, contNo2_2, contNo3_2, contNo4_2, contNo5_2, contNo6_2, datetime) VALUES ('$_POST[contNo_1]','$_POST[contNo2_1]','$_POST[contNo3_1]','$_POST[contNo4_1]','$_POST[contNo5_1]','$_POST[contNo6_1]','$_POST[contNo_2]','$_POST[contNo2_2]','$_POST[contNo3_2]','$_POST[contNo4_2]','$_POST[contNo5_2]','$_POST[contNo6_2]',NOW())"; if (!mysqli_query($con,$sql)) { die('<font color="#FF0000"><h2>Error: ---PLEASE CHECK YOUR NUMBER AGAIN....<br />Press Back on the browser.... </h2></font>' . mysqli_error($con)) ; } else header('location: /bldrft/edits/view.php'); mysqli_close($con); ?> I can't figure it out what was the wrong, all are fine to me, plzz help guys. thanks.
  15. I am having trouble writing exactly 4 queries in mysql. Here is the view I am using for queries: http://pastie.org/8403299 Here is the Raw Data you can check http://goo.gl/z7Vv9X which you can check. What is needed: 1) Gained students are those who exist in the selected / filtered month and don't exist in the previous month. 2) Lost students are those who exist in the previous month of the selected / filtered month and don't exist in the selected / filtered month. 3) Get a list of all lost students since the start of the center till now(). 4) Get a list of all gained students since the start of center till now. I am currently stuck with query 1) (Gained students are those who exist in the selected / filtered month and don't exist in the previous month.) I have written it like that (see just below), but I get the same number of rows back if I haven't filtered anything... uff. SELECT * FROM lessons_master_001 my1 WHERE NOT EXISTS ( SELECT 0 FROM lessons_master_001 my2 WHERE my1.student_id = my2.`student_id` AND my1.teacher_id = my2.teacher_id AND my1.`student_payment_id`= my2.`student_payment_id`AND CONCAT(CAST(MONTH(DATE_ADD(my1.Lesson_Booking_Date, INTERVAL -1 MONTH))AS CHAR(20)),CAST(YEAR(DATE_ADD(my1.Lesson_Booking_Date, INTERVAL -1 MONTH))AS CHAR(20))) = CONCAT(CAST(MONTH(my2.`Lesson_Booking_Date`)AS CHAR(20)),CAST(YEAR(my2.`Lesson_Booking_Date`)AS CHAR(20))) ) My logic is like this so I take everything from the view lessons_master_001 and give alias my1 and in the NOT EXISTS clause I am giving to the same dataset alias my2, then join those ID's that are also used in view lessons_master_001 and then try to connect previous month from data set my1 with current month from data set my2. I am using DATE_ADD function to subtract month from current date and practically get date - 1 month. I would really appreciate any help you will provide, cause I lost 2 days already on it with no progress in front. Thank you in advance.
  16. Good day Hope someone can help me. I am working on an Intranet project, the aim is to create a medical intranet system. Please help me with the following. 1. I have created users on my database(called medionline) and stored the relevant information in table employees. 2. I have a script which searches for the name and surname of the employees in the database 3. When a match is found, it then prints the details. The search functionality works but not as I want it to work, this is where I need help. It should do the following. a. Search for a user using either the name, surname or username b. When a match is found, it will then display all the details about the specific user(name, surname, id number, contact number, jobtile and username_ in a form, meaning a new form will have to be set up with these fields. This will allow me to create buttons within the form with the users details where I can delete users, update users or create new users. Your assistance in this will be highly appreciated. This is my search.php page <?php /* * author :basetsanamnl0@gmail.com * * * */ include 'connection.php'; $connection = new createConnection(); // creating connection $connect = $connection->connectToDatabase(); // connect to database $connection->selectDatabase(); // select database //-------------------QUERY--------------------------------------// $query = $_GET['query']; // gets value sent over search form $min_length = 3; // you can set minimum length of the query if you want if(strlen($query) >= $min_length){ // if query length is more or equal minimum length then $query = htmlspecialchars($query); // changes characters used in html to their equivalents, for example: < to > $query = mysql_real_escape_string($query); // makes sure nobody uses SQL injection $raw_results = mysql_query("SELECT * FROM employees WHERE (`name` LIKE '%".$query."%') AND (`surname` LIKE '%".$query."%')") or die(mysql_error()); // * means that it selects all fields, you can also write: `id`, `title`, `text` // articles is the name of our table // '%$query%' is what we're looking for, % means anything, for example if $query is Hello // it will match "hello", "Hello man", "gogohello", if you want exact match use `title`='$query' // or if you want to match just full word so "gogohello" is out use '% $query %' ...OR ... '$query %' ... OR ... '% $query' if(mysql_num_rows($raw_results) > 0){ // if one or more rows are returned do following while($results = mysql_fetch_array($raw_results)){ // $results = mysql_fetch_array($raw_results) puts data from database into array, while it's valid it does the loop echo "<p><h3>".$results['name']."</h3>".$results['surname']."</p>"; // posts results gotten from database(title and text) you can also show id ($results['id']) } } else{ // if there is no matching rows do following echo "No results"; } } else{ // if query length is less than minimum echo "Minimum length is ".$min_length; } This is my search.index.php page <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Medi_online</title> <link type="stylesheet" rel="stylesheet" href="main.css"/> <script src="buttons.js"></script> <script src="connect.js"></script> <script src="slider.js"></script> </head> <!---Website Design by Basetsana Manele medi_online intranet system 2013 Contact: basetsanamnl0@gmail.com --> <body> <!--Twitter and Facebook connect tabs----> <div class="s-connect"> <div class="Fbutton"> <div class="facebook"> <img src="images/social_media/Facebook.png"/> </div> <div class="cont"></div>a </div> <div id="clear"></div> <div class="Tbutton"> <div class="twitter"> <img src="images/social_media/twitter.png"/> </div> <div class="Tcont"></div> </div> <div id="clear"></div> </div> <div id="clear"></div> <!--------------------------------------------------> <div id="weblinks"> <div id="link"><a href="../medionline/logout.php" target="_new">Logout | </a></div> <div id="link"><a href="../medionline/admin_login.php"target=_"new">Admin Login </a></div> </div> <!-------Banner------------------> <div id="banner"> </div> <!-------Main Navigation---------> <div id="nav"> <div class="nav_bs" style="width:175px;" ><a style="color:#e1e1e1;" href="index.html">INTRANET HOME</a></div> <div class="nav_bs" style="width:180px;" ><a style="color:#e1e1e1;" href="about_fisha.html">EMPLOYEE TOOLS</a></div> <div class="nav_bs" style="width:250px;" ><a style="color:#e1e1e1;" href="healthcare.html">COLLOBORATION TOOLS</a></div> <div class="nav_bs" style="width:190px;" ><a style="color:#e1e1e1;" href="training.html">DEPARTMENT HUB</a></div></div> <!-------Paitent information sign up-------> <div id="container_main"> <h3 align="center">SEARCH USER</h3> <br/> <h5 align="justify"> Please enter either name, surname or username to search.</h5> <br/> <form action="search.php" method="GET"> <table width="500" border="0" cellpadding="0"> <input type="text" name="query" /> <input type="submit" value="Search" /> <tr> <td> </td> </tr> </form> </div> </body> </html>
  17. I have a question re a project I'm doing in php/mysql. I am designing a site where users can record their financial accounts (bank account/credit cards etc) and the transactions and their type that they undertake on a monthly basis on each one of them. What I want is that the user selects a particular account and using GET I can take the account id, and use that to get all transactions associated with that account name from a different table in the database. I get the error trying to get the property of non-object and I'm unsure where I have gone wrong. Ive put some echo comments in previously and can see the GET is working and the initial statement works and I can retrieve the Accname using the ID. It appears to be the next part where I take that Accname that I have got and try to use it to get data from another table that I run into problems. Here is my code, apologies if its ugly I am really only learning this and piecing together bits and pieces from various online tutorials. <?php //connect to database include ('connect-To-db.php'); $id = $_GET['id']; if($stmt = $mysqli->prepare("SELECT `Accname` FROM `Account` WHERE `accID`=?")){ $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($Accname); while($stmt->fetch()){ $query = $mysqli->query("SELECT `Credit`, `Debit`, `Catagory` FROM `transactions WHERE `Accname`=$Accname"); if($query->num_rows>0){ echo "Yes"; } else{ echo "No"; } } else { echo "ERROR"; }
  18. Hello Everybody..! I a new to php and I am developing a payment page. Now im struck in one place. my query is: when user visits a payment page. The auto increment id should be generated in database and should display in textbox. I tried googling bt could not found it pls help Thanks in advance
  19. I use PHP to bridge between an obscure programming language (AutoHotKey) and a MySQL backend. This leads me to 2 questions 1) Should I be concerned about latency? There are times that I have to make a few hundred inserts at a time and then there's only a short pause before a few hundred more inserts. 2) I'm using a system that seems like it's not the best way to use PHP to bridge the gap. I use HTTP encoded URLs to get & set information. So this query would translate into that URL. Is there a better way with PHP? INSERT INTO testTable (id, channel, status, datetime) VALUES ('1', '23', '3', NOW()); http://Mywebsite.com/php/ahk2sql.php?key=01010AuthenticationKey0101010&query=INSERT%2520INTO%2520testTable%2520%28id%2C%2520channel%2C%2520status%2C%2520datetime%29%2520VALUES%2520%28%271%27%2C%2520%2723%27%2C%2520%273%27%2C%2520NOW%28%29%29%3B
  20. I am pulling some data out of a MySQL database and echoing it out (pretty standard stuff) What is really confusing me is I have checked the query using phpMyAdmin and it returns 1 row which is what i expect. I've even double checked by using a COUNT query and i get the same result. The problem is when I run the returned array through a foreach loop to populate a new array, it appears to create 2 new array rows and i think it's to do with my IF statements. What i want to do in the IF is check is a certain value is present. If not, check that the value is a number and a certain length out of 2 conditions. If not, then do nothing. I'm looking for 3 conditions. Could the problem be that the field type in the database is a varchar and i'm checking for a number? Here is my code $allowed = array('param1', 'param2', 'param3'); //if(isset($_POST['submit'])) { //$sql = 'SELECT consignment_number FROM tracker WHERE order_number = 2893214 AND consignment_number IS NOT NULL'; $sql = 'SELECT column1, column2 FROM table WHERE column1 = :placeholder AND CHAR_LENGTH(column2) > 1'; $stmt = $db->prepare($sql); //$stmt->bindValue('order', $_POST['order']); $stmt->bindValue(':placeholder', $val); $stmt->execute(); $rows = $stmt->fetchAll(); echo count($rows).'<br />'; //echos 1 as checked in phpMyAdmin if(count($rows) != 0) { $myarray = array(); foreach($rows as $row) { $test = $row['column2']; //do something if ($test == 'RM') { // despatched by royal mail $myarray['column1'] = "param1"; $myarray['column2'] = $test; } elseif ( ctype_digit($test) && (strlen($test) == ) { // going by FedEx? $myarray['column1'] = "param2"; $myarray['column2'] = $test; } elseif ( ctype_digit($test) && (strlen($test) == 11) ) { // going by TNT? $myarray['column1'] = "param3"; $myarray['column2'] = $test; } } } else { //no rows } echo count($myarray); echo '<pre>';var_dump($myarray);echo'</pre>'; if(in_array($myarray['column1'], $allowed)) { foreach ($myarray as $array) { if(!empty($myarray['column1'])) { echo $myarray['column1'].': '.$myarray['column2'].'<br />'; } } } else { }
  21. I have two tables, brands and devices. brands table is set up like so: id | brand_name 1 Apple 2 Samsung devices: id | brand_id | dev_model | dev_version 1 1 iPhone 5s 2 2 Galaxy S4 Right now I can search for a phone by its device name, for example: 'iPhone 5s', but I need my users to be able to search for the brand too: 'Apple iPhone 5s'. Is there a practical approach to doing this without having to add the brand names in my device table? This is my current MySQL query: $sql = "(SELECT id, brand_id, dev_model, dev_version FROM devices WHERE "; $sql .= "CONCAT(dev_model, ' ', dev_version) LIKE '%{$database->escape_values($term)}%' "; $sql .= "LIMIT 4)"; Any help would be appreciated, or even a point in the right direction.
  22. Hello, I have a function to get a users rank in a contest and need some help on sorting it by a different means. Right now it take entries*referrals and then sorts based upon that but I want to be able to sort multiple ways. Right now if the user has no referrals they are not included in the sorting process and I can't get my mind wrapped around how to include all of them. For example it should work like this user1 5 entries 2 referrals for a total of 10 user2 0 entries 0 referrals for a total of 0 user3 3 entries 1 referrals for a total of 3 user4 0 entries 0 referrals for a total of 0 user5 100 entries 0 referrals for a total of 100 In my mind user5 should rank #1 as the total is 100 user1 should be 2nd as total is 10 user3 should be third as total is 3 user2 would be 4th as total is zero then (based upon id) user4would be 5th as total is zero then (based upon id) But what it does is this user1 is ranked 1st user3 is ranked 2nd user2 and user4 and user5 are left out because they have no referrals any help would be greatly appreciated. here is the code function get_user_rank($usrid,$contest_start,$type) { $conteststart = date('Y-m-d', strtotime(date('Y-1-1'))); $res = mysql_query("SELECT m1.referid, m2.name, m2.lastname, m2.userid, m2.".$type." as entries, count(*) as referrals FROM members m1 inner join members m2 on m1.referid=m2.userid where m2.verified=1 and m1.verified=1 and m1.joindate > '".$contest_start."' group by m1.referid, m2.name ORDER BY entries DESC"); while ( $r = mysql_fetch_assoc($res) ) { $mdata[$r['userid']]['userid'] = $r['userid']; $mdata[$r['userid']]['total_entries'] = $r['entries'] * $r['referrals']; } usort($mdata, 'sort_leaders'); for ( $i=0; $i < count($mdata); $i++ ) { if ( $mdata[$i]['userid'] == $usrid ) return $i+1; next($mdata); } return 0; } function sort_leaders($a, $b) { if ( $a['total_entries'] == $b['total_entries'] ) return 0; return ( $a['total_entries'] > $b['total_entries'] ) ? -1 : 1; } $year_start = date('Y-m-d', strtotime(date('Y-1-1'))); get_user_rank($userid,$year_start,"contesty");
  23. Hi and thanks in advance. The following code is supposed to insert a record in a MySql tab anf for reason its not inserting anything. It was working but since adding the textarea's and dropdown it has stopped. There is no error message. Any ideas? <form method="post"> <table> <tr> <td>Resort Name</td> <td><input type="text" name="resortname" /></td> </tr> <tr> <td>Ric No.</td> <td><input type="text" name="ric" /></td> </tr> <tr> <td valign="top">Resort Description</td> <td><textarea name="resortdesc" cols="50" rows="6"></textarea></td> </tr> <tr> <td valign="top">Address</td> <td><textarea name="address" cols="50" rows="6"></textarea></td> </tr> <tr> <td>Exchange</td> <td><input type="text" name="exchange" /></td> </tr> <tr> <td>Check in day</td> <td><input type="text" name="checkinday" /></td> </tr> <tr> <td>Resort Status</td> <td><input type="text" name="rstatus" /></td> </tr> <tr> <td>Golf Facilities</td> <td><select name="rgolf"> <option value="TRUE">TRUE</option> <option value="FALSE">FALSE</option> </select></td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" value="add" /></td> </tr> </table> <?php if (isset($_POST['submit'])) { include 'db.php'; $resortname=$_POST['resortname'] ; $ric= $_POST['ric'] ; $resortdesc=$_POST['resortdesc'] ; $address=$_POST['address'] ; $exchange=$_POST['exchange'] ; $checkinday=$_POST['checkinday'] ; $rstatus=$_POST['rstatus'] ; $rgolf=$_POST['rgolf'] ; mysql_query("INSERT INTO `Resort`(ResortName,Ric,ResortDesc, Address, Exchange, CheckinDay, RStatus, RGolf ) VALUES ('$resortname','$ric', '$resortdesc','$address','$exchange','$checkinday,'$rstatus','$rgolf')"); } ?> </form>
  24. Hi All, I have 'inherited' a project where the database / dates are a bit screwed up. I have been handed a simple table with the column titles... RecordId InputDate MySqlDate (which i added) The id is the id, the InputDate unfortunately is a tinytext where the input format is for example... 20/08/2013 or 20/8/2013 I have added the MySqlDate as a date column to make everything easier for new entries / queries and all is good. Now I need to convert / update the existing data from the InputDate column to the respective MySqlDate column. i.e. from the tinytext to date - 0000-00-00 Got me stumped. Any tips appreciated. Rik
  25. Hi, I am not asking for code, If you provide it thank you but I am happy to do the work myself I am more after the concept and code snippets. My Goal, I have 2 domains for this I will use www.1.com and www.2.com to make it easy. 1.com has a couple lines of javascript and 2 variables 1 being a domain and the other being a unique ID 2.com has a php script which is called by 1.com when the page is loaded (somehow) it will check the Unique ID and the domain that they match in a mySQL database and if they do to run another javascript script. If it does not to just end itself. The problem I have is I know PHP to an average level but Javascript well below average. I need to know how to run the PHP script from an external site 1.com to run a generic PHP script from 2.com and use the variables from 1.com to check the database at 2.com for a match and to either say yes matching display: or not matching deny. If anyone has any ideas on how to do this or something they have done before that would be awesome. I am wanting to to put the javascript on 10 different websites with different variables and for 2.com to just do the checking. for security reasons I need the URL to be checked so if 1.com loads and says the URL is 1.com but infact the user loaded 55.com it needs to be denied so PHP on 2.com needs to know where the request came from which domain... PLEASE HELP
×
×
  • 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.