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. hi, guys i managed to load contents from database dynamically using ajax (JQUERY) but the problem is i'm not able to make them work properly, as i have jquery events to hide classes that are not hiding and links that wont do their normal behaviour when clicked. dont know where i'm going wrong. Any help would be appreciated. here is the jquery code that loads data dynamically: //logic for infinite scroll var load=0; var sess_uname="<?php echo $session_uname;?>"; var f_uname="<?php echo $f_uname;?>"; var sess_count="<?php echo $total_sess_count;?>"; var f_count="<?php echo $total_friend_count;?>"; if(sess_uname==f_uname){ $(window).scroll(function(){ if($(window).scrollTop()==$(document).height()-$(window).height()){ load++; if(load *2 >sess_count){ $(".message").text("no more posts to show"); }else{ $.post("st&com.php", {load:load},function(data){ $("#status_area").append(data); }); } } }); } here is the code for dynamically loaded elements in php: <?php include "includes/dbconfig.inc.php"; $status_replies=""; $status_list=""; $statusui_edit=""; $isowner=""; $is_friend=""; $statusdeletebutton=''; $reply_delete_button=""; $load= (int)($_POST['load'])*2; function hashtags($dat) { $regex="/#+([a-zA-z0-9._-]+)/"; $dat1= preg_replace($regex, '<a href="hash_sys.php?tag=$1">$0</a>', $dat); return $dat1; } function taggingsys($dat) { $regex="/@+([a-zA-z0-9!._-]+)/"; $dat1= preg_replace($regex, '<a href="home.php?u=$1">$0</a>', $dat); return $dat1; } $sess_id=(int)$_SESSION['id']; $friends = array(); $stmt= $conn->prepare("select friend_one, friend_two from friends where (friend_one=:session OR friend_two=:session) and accepted='1'"); $stmt->bindparam(":session",$_SESSION['uname']); $stmt->execute(); $fetch=$stmt->fetchAll(); $count=count($fetch); if($count==0){ $totalids=$project->totalUpdates1($sess_id,$load); /* foreach ($totalids as $v) { print_r($v); $id=$v['user_id']; //fetch update_id from update table in db and inject it to the feed query. //$totalUpdates=$project->totalUpdates1($id); */ foreach ($totalids as $row1){ $updateid=$row1['update_id']; $account_name=$row1['account_name']; $u_id=$row1['user_id_u']; $author=$row1['author']; $post_date=$row1['time']; $title= stripslashes($row1['title']); $data= stripslashes($row1['update_body']); $data1= hashtags($data); // $data1= taggingsys($data0); $pic=$project->viewByUname($author); $uid=$pic['user_id']; $datemade = strftime("%B %d", strtotime($post_date)); $avatar=$pic['avatar']; if ($avatar!=""){ $feed_pic='user/'.$uid.'/'.$avatar; } else { $feed_pic='img/avatardefault.png'; } include 'ratings/vote_count.php'; $like='<a type="like" class="btn status_like_'.$updateid.' like" attr="'.$updateid.'">Like</a>('.$num_likes[0].')'; $unlike='<a type="unlike" class="btn status_unlike_'.$updateid.' unlike" attr="'.$updateid.'">Dislike</a>('.$num_unlikes[0].')'; $share_button=""; $hidden_text= '<textarea class="hidden_textarea hidden_value'.$updateid.'" type="hidden" disabled>'.$data1.'</textarea>'; $share_button="<a class='btn share_btn share_".$updateid."' title='".$title."' type='share' id='".$updateid."'>Share</a>"; if ($author==$_SESSION['uname'] || $account_name==$_SESSION['uname']) { $statusdeletebutton='<li>' . '<a type="'.$updateid.'" class="btn delete_4_session hidden_text_delete_'.$updateid.' glyphicon glyphicon-trash delete_status_btn" title="Delete this status and its replies">Remove</a></li>'; $edit_btn='<li>' . '<a attr="'.$updateid.'" type="'.$updateid.'" class="btn edit_4_session hidden_text_edit glyphicon glyphicon-pencil" title="Edit this status" >Edit</a></li>'; $statusui_edit="<div type='".$updateid."' class='hidden_edit_4_session session_editor".$updateid." jumbotron'>" . "<a type='".$updateid."' class='btn pull-right close_edit' title='Close without editing'>Close X</a>" . "<input type='text' class='form-control title_s_edit title_s_".$updateid."' name='status_title' value='".html_entity_decode($title)."' placeholder='Title' >" . "<span> </span>" . "<textarea id='wall_edit_1' type='".$updateid."' rows='5' cols='50' class='session_edit text_value_".$updateid."' wrap='hard' placeholder='whats up ".$session_uname."'> ".html_entity_decode($data1)."</textarea><br>" . "<button style='float:right;' value='".$updateid."' type='a' class='btn btn-warning btn btn-large btn-lg post-s-edit'>Update</button></div>" ; }else{ $statusdeletebutton=""; $edit_btn="<li class='posted'>You are not the owner of this Post</li>"; $statusui_edit=""; } echo $statusui_edit.''. $hidden_text.'<div attr="'.$updateid.'" type="'.$updateid.'" class="statusboxes status_'.$updateid.' jumbotron">' . '<h3 class="pull-left title">' . '<div id="'.$updateid.'" class="title_s_2copy posted" value="'.html_entity_decode($title).'">'.html_entity_decode($title).'</div></h3>' . '<span class="pull-right">' . '<div class="dropdown">' . '<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" >' . '<span class="glyphicon glyphicon-edit"></span></button>' . '<ul class="dropdown-menu">' .$edit_btn .' '. $statusdeletebutton .'</ul></div></span><br><hr>' . '<legend><span style="font-size: 13.5px;" class=" data_s_2copy" type="'.$updateid.'" >' . html_entity_decode($data1).'</span></legend><b class="posted"><small>Posted by:- <a href="home.php?u='.$author.'"><img src="'.$feed_pic.'" height="20px" width="20px"> '.$author. '</a> '.$datemade.'</small></b>' . '<br><legend>'.$like.' | '.$unlike. ' | '.$share_button.'<h4><a id="'.$updateid.'" class="btn collap-btn">Comments</a></h4></legend>'; ?> <!-- Collapsible Element HTML --> <?php // Fetch Comments of update echo '<div id="toggle'.$updateid.'" class="collapse">'; $totalComments=$project->totalComments($_SESSION['uname'],$friend,$updateid); foreach($totalComments as $row1){ $status_reply_id=$row1['comment_id']; $reply_d=htmlentities($row1['comment_body']); $reply_data= stripslashes($reply_d); $reply_osid=$row1['os_id']; $reply_date=$row1['time_c']; $reply_author=$row1['author_c']; $reply_data1= hashtags($reply_data); // $reply_data1= taggingsys($reply_data0); $datemade_r = strftime("%B %d", strtotime($reply_date)); include 'ratings/vote_count4comments.php'; $like_r='<a type="like" class="btn status_liker_'.$status_reply_id.' like_r" attr="'.$status_reply_id.'">Like</a>('.$num_likes_r.')'; $unlike_r='<a type="unlike" class="btn status_unliker_'.$status_reply_id.' unlike_r" attr="'.$status_reply_id.'">Dislike</a>('.$num_unlikes_r.')'; $pic=$project->viewByUname($reply_author); $uid=$pic['user_id']; $avatar=$pic['avatar']; if ($avatar!=""){ $feed_r_pic='user/'.$uid.'/'.$avatar; } else { $feed_r_pic='img/avatardefault.png'; } if ($reply_author==$_SESSION['uname'] ) { $reply_delete_button='<li><a type="'.$status_reply_id.'" class="btn delete_reply_btn glyphicon glyphicon-trash delete_reply_"'.$status_reply_id.'" title="Delete this comment"> Remove</a></span></li>'; } else{ $reply_delete_button=""; } echo ' <div class="replyboxes pull-left reply_' .$status_reply_id.'">' . 'Reply by:- ' . '<a href="home.php?u='.$reply_author. '"><img src="'.$feed_r_pic.'" height="20px" width="20px">'.$reply_author.'</a>' . '<span class="pull-right">'.$datemade_r . '<b class="dropdown"> <small><span class="btn btn-xs btn-danger dropdown-toggle pull-right" data-toggle="dropdown" > <span class="glyphicon glyphicon-edit"></span></span> <ul class="dropdown-menu">'.$reply_delete_button . '</ul></span>' . '</small></b><br><legend>'. html_entity_decode($reply_data1).'<br>'.$like_r.'|'.$unlike_r.'</legend></div>'; } echo '<textarea id="reply_textarea_'.$updateid.'" class="status_reply_'.$updateid.' input-custom2" placeholder="comment\'s"></textarea>' . '<button id="reply_butn_'.$updateid.'" attr="'.$updateid.'" type="b" class="btn btn-warning pull-right btn-sm reply_butn reply_'.$updateid.'">Reply</button></div></div>'; } } //} else{ $friends = array(); $stmt= $conn->prepare("select friend_one, friend_two from friends where (friend_one=:session OR friend_two=:session) and accepted='1'"); $stmt->bindparam(":session",$_SESSION['uname']); $stmt->execute(); foreach ($stmt->fetchAll() as $i=> $r ) { $r["friend_one"] == $_SESSION['uname'] ? $friends[]= $r["friend_two"] : $friends[] = $r["friend_one"]; $friend=$friends[$i]; $friend_count=count($friends); $totalids=$project->totalids($_SESSION['uname'],$friend); foreach ($totalids as $v) { $id=$v['user_id']; //fetch user_id from update table in db and inject it to the feed query. $totalUpdates=$project->totalUpdates1($id,$load); $total_sess_count=$project->totalupdatescount($id); foreach ($totalUpdates as $j=>$row1){ $updateid=$row1['update_id']; $account_name=$row1['account_name']; $u_id=$row1['user_id_u']; $author=$row1['author']; $post_date=$row1['time']; $title= stripslashes($row1['title']); $data= stripslashes($row1['update_body']); $data1= hashtags($data); //$data1= taggingsys($data0); $pic=$project->viewByUname($author); $uid=$pic['user_id']; $datemade = strftime("%B %d", strtotime($post_date)); $avatar=$pic['avatar']; if ($avatar!=""){ $feed_pic='user/'.$uid.'/'.$avatar; } else { $feed_pic='img/avatardefault.png'; } include 'ratings/vote_count.php'; $like='<a type="like" class="btn status_like_'.$updateid.' like" attr="'.$updateid.'">Like</a>('.$num_likes[0].')'; $unlike='<a type="unlike" class="btn status_unlike_'.$updateid.' unlike" attr="'.$updateid.'">Dislike</a>('.$num_unlikes[0].')'; $share_button=""; $hidden_text= '<textarea class="hidden_textarea hidden_value'.$updateid.'" disabled>'.$data.'</textarea>'; $share_button="<a class='btn share_btn share_".$updateid."' title='".$title."' type='share' id='".$updateid."'>Share</a>"; if ($author==$_SESSION['uname'] || $account_name==$_SESSION['uname']) { $statusdeletebutton='<li>' . '<a type="'.$updateid.'" class="btn delete_4_session hidden_text_delete_'.$updateid.' glyphicon glyphicon-trash delete_status_btn" title="Delete this status and its replies">Remove</a></li>'; $edit_btn='<li>' . '<a attr="'.$updateid.'" type="'.$updateid.'" class="btn edit_4_session hidden_text_edit glyphicon glyphicon-pencil" title="Edit this status" >Edit</a></li>'; $statusui_edit="<div type='".$updateid."' class='hidden_edit_4_session session_editor".$updateid." jumbotron'>" . "<a type='".$updateid."' class='btn pull-right close_edit' title='Close without editing'>Close X</a>" . "<input type='text' class='form-control title_s_edit title_s_".$updateid."' name='status_title' value='".html_entity_decode($title)."' placeholder='Title' >" . "<span> </span>" . "<textarea id='wall_edit_1' type='".$updateid."' rows='5' cols='50' class='session_edit text_value_".$updateid."' wrap='hard' placeholder='whats up ".$_SESSION['uname']."'> ".html_entity_decode($data1)."</textarea><br>" . "<button style='float:right;' value='".$updateid."' type='a' class='btn btn-warning btn btn-large btn-lg post-s-edit'>Update</button></div>" ; }else{ $statusdeletebutton=""; $edit_btn="<li class='posted'>You are not the owner of this Post</li>"; $statusui_edit=""; } echo $statusui_edit.''. $hidden_text.'<div attr="'.$updateid.'" type="'.$updateid.'" class="statusboxes status_'.$updateid.' jumbotron">' . '<h3 class="pull-left title">' . '<div id="'.$updateid.'" class="title_s_2copy posted" value="'.html_entity_decode($title).'">'.html_entity_decode($title).'</div></h3>' . '<span class="pull-right">' . '<div class="dropdown">' . '<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" >' . '<span class="glyphicon glyphicon-edit"></span></button>' . '<ul class="dropdown-menu">' .$edit_btn .' '. $statusdeletebutton .'</ul></div></span><br><hr>' . '<legend><span style="font-size: 13.5px;" class=" data_s_2copy" type="'.$updateid.'" >' . html_entity_decode($data1).'</span></legend><b class="posted"><small>Posted by:- <a href="home.php?u='.$author.'"><img src="'.$feed_pic.'" height="20px" width="20px"> '.$author. '</a> on '.$datemade.'</b>' . '<br><legend>'.$like.' | '.$unlike. ' | '.$share_button.'</legend></small>'; ?> <h4><a id="<?php echo $updateid;?>" class="btn collap-btn">Comments</a></h4> <!-- Collapsible Element HTML --> <div id="toggle<?php echo $updateid;?>" class="collapse scroll-comments"> <?php // Fetch Comments of update $totalComments=$project->totalComments($_SESSION['uname'],$friend,$updateid); foreach($totalComments as $row1){ $status_reply_id=$row1['comment_id']; $reply_d=htmlentities($row1['comment_body']); $reply_data= stripslashes($reply_d); $reply_osid=$row1['os_id']; $reply_date=$row1['time_c']; $reply_author=$row1['author_c']; $reply_data1= hashtags($reply_data); //$reply_data1= taggingsys($reply_data0); $datemade_r = strftime("%B %d", strtotime($reply_date)); include 'ratings/vote_count4comments.php'; $like_r='<a type="like" class="btn status_liker_'.$status_reply_id.' like_r" attr="'.$status_reply_id.'">Like</a>('.$num_likes_r[0].')'; $unlike_r='<a type="unlike" class="btn status_unliker_'.$status_reply_id.' unlike_r" attr="'.$status_reply_id.'">Dislike</a>('.$num_unlikes_r[0].')'; $pic=$project->viewByUname($reply_author); $uid=$pic['user_id']; $avatar=$pic['avatar']; if ($avatar!=""){ $feed_r_pic='user/'.$uid.'/'.$avatar; } else { $feed_r_pic='img/avatardefault.png'; } if ($reply_author==$_SESSION['uname'] ) { $reply_delete_button='<li><a type="'.$status_reply_id.'" class="btn delete_reply_btn glyphicon glyphicon-trash delete_reply_"'.$status_reply_id.'" title="Delete this comment"> Remove</a></span></li>'; } else{ $reply_delete_button=""; } echo ' <div class="replyboxes pull-left reply_' .$status_reply_id.'">' . 'Reply by:- ' . '<a href="home.php?u='.$reply_author. '"><img src="'.$feed_r_pic.'" height="20px" width="20px"> '.$reply_author.'</a>' . '<span class="pull-right">'.$datemade_r . '<b class="dropdown"> <small><span class="btn btn-xs btn-danger dropdown-toggle pull-right" data-toggle="dropdown" > <span class="glyphicon glyphicon-edit"></span></span> <ul class="dropdown-menu">'.$reply_delete_button . '<li><a class="glyphicon glyphicon-warning-sign" href="report.php?u='.$reply_author.'"> Report</a><li></ul></span>' . '</small></b><br><legend>'. html_entity_decode($reply_data1).'<br>'.$like_r.'|'.$unlike_r.'</legend></div>'; } echo '<textarea id="reply_textarea_'.$updateid.'" class="status_reply_'.$updateid.' input-custom2" placeholder="comment\'s"></textarea>' . '<button id="reply_butn_'.$updateid.'" attr="'.$updateid.'" type="b" class="btn btn-warning pull-right btn-sm reply_butn reply_'.$updateid.'">Reply</button></div></div>'; } }} }?> Thanks in advance.
  2. Guys i'm trying to create a infinite scroll feature for a project of mine and i couldn't make it work in the infinite scroll fashion any inputs would be appreciated. Jquery code: $(document).ready(function(){ var load=0; var sess_uname="<?php echo $session_uname;?>"; var f_uname="<?php echo $f_uname;?>"; var sess_count="<?php echo $total_sess_count;?>"; var f_count="<?php echo $total_friend_count;?>"; if(sess_uname==f_uname){ $(window).scroll(function(){ if($(window).scrollTop()==$(document).height()-$(window).height()){ load++; alert('hai1'); if(load *5 >sess_count){ $(".message").text("no more posts to show"); }else{ $.post("st&com.php", {load:load},function(data){ // $(".status_area").append(data); alert('hai'); }); } } }); } }); here is the php code: $load= (int)($_POST['load'])*2; $sess_id=(int)$_SESSION['id']; $friends = array(); $stmt= $conn->prepare("select friend_one, friend_two from friends where (friend_one=:session OR friend_two=:session) and accepted='1'"); $stmt->bindparam(":session",$_SESSION['uname']); $stmt->execute(); $fetch=$stmt->fetchAll(); $count=count($fetch); if($count==0){ $totalids=$project->totalUpdates1($sess_id,$load); here is the class: public function totalUpdates1($id, $load) { $sql2="SELECT * FROM updates WHERE user_id_u=:id order by time desc limit $load,5"; $stmth= $this->_db->prepare($sql2);//Check here syntax of $db $stmth->bindValue(":id",$id); //$stmth->bindValue(":load",$load); $stmth->execute(); return $stmth->fetchAll(); }
  3. I am trying to insert multiple rows to a column in mysql like this: INSERT INTO `sportsapp`.`exercises` (`id`, `image_path`, `name`, `category`) VALUES ('3', 'exercises/biceps/barbell_curls_lying_against_an_incline.jpg', 'Barbell Curls Lying Against An Incline', 'Biceps'), ('4','exercises/biceps/cable_hammer_curls_-_rope_attachment','Cable hammer Curls - Rope Attachment','Biceps'); I am getting an error in return: I tried to google and understand what's the reason for it, but I dont get it. I do have already a primary key, and I don't know why it generates another primary key, Could you please try to help with this?
  4. Hi everyone, I'm new here and i'm also new with coding in PHP. I have written one Restful Api based on one tutorial and i need Restful Api for connecting my Android application to server. I need some help with making this to work. I need to update user details. This is the code i'm using: class DbHandler { public function updateUser($id, $name) { $stmt = $this->conn->prepare("UPDATE users SET name = ? WHERE id = ?"); $stmt->bind_param("is", $id, $name); $stmt->execute(); $num_affected_rows = $stmt->affected_rows; $stmt->close(); return $num_affected_rows > 0; } } This is preparation statement for updating a existing user. Now here is a fragment of code from index.php where i'm calling all methods: $app->put('/user/:id', 'authenticate', function($id) use($app) { verifyRequiredParams(array('name')); global $id; $name = $app->request->put('name'); $db = new DbHandler(); $response = array(); $result = $db->updateUser($id, $name); if ($result) { $response["error"] = false; $response["message"] = "User updated successfully"; } else { $response["error"] = true; $resopnse["message"] = "User failed to update. Please try again"; } echoRespnse(200, $response); }); When i try to send request, i'm getting only this: { "error": true } Any help would be appreciated. Thanks.
  5. Can some one help to generate a unique Doctor Appointment ID when some one save the registration form, I am trying to make online doctor appoint booking system, I want something like for each doctor, each date, it will generate a unique id, that may be something like following Dr_ID-Date-Auto increment number( DR001-03-23-2016-0001 ) If any one have better idea to generate a short and unique id, please suggest me. I am a beginner in PHP, please help me guys
  6. I feel like this should be easy but I am stuck. I am attempting to create a form that will dynamically update rows using radiobuttons selected by the user. It is a questionnaire. Next will be figuring out the best way to use pagination and update only the records displayed on that page. Thanks in advanced Assessment.php <form action="Process/Process.php" method="post"> <?php do { ?> <label><?php echo $row_Questions['Questions']; ?></label> <label> <input <?php if (!(strcmp($row_Questions['Value'],"1"))) {echo "checked=\"checked\"";} ?> type="radio" name="Value[<?php echo $row_Questions['QuestionID']; ?>]" class="icheck" data-radio="iradio_square-blue" value="1"> Strongly Disagree </label> <label> <input <?php if (!(strcmp($row_Questions['Value'],"2"))) {echo "checked=\"checked\"";} ?> type="radio" name="Value[<?php echo $row_Questions['QuestionID']; ?>]" class="icheck" data-radio="iradio_square-blue" value="2"> Disagree </label> <label> <input <?php if (!(strcmp($row_Questions['Value'],"3"))) {echo "checked=\"checked\"";} ?> type="radio" name="Value[<?php echo $row_Questions['QuestionID']; ?>]" class="icheck" data-radio="iradio_square-blue" value="3"> Neutral </label> <label> <input <?php if (!(strcmp($row_Questions['Value'],"4"))) {echo "checked=\"checked\"";} ?> type="radio" name="Value[<?php echo $row_Questions['QuestionID']; ?>]" class="icheck" data-radio="iradio_square-blue" value="4"> Agree </label> <label> <input <?php if (!(strcmp($row_Questions['Value'],"5"))) {echo "checked=\"checked\"";} ?> type="radio" name="Value[<?php echo $row_Questions['QuestionID']; ?>]" class="icheck" data-radio="iradio_square-blue" value="5"> Strongly Agree </label> <input type="hidden" name="AnswerID[]" value="<?php echo $row_Questions['AnswerID']; ?>"> <input type="hidden" name="QuestionID[]" value="<?php echo $row_Questions['QuestionID']; ?>"> <input type="hidden" name="UserID[]" value="User"> <?php } while ($row_Questions = mysql_fetch_assoc($Questions)); ?> <input type="submit" name="ValueAssessmen" value="Submit"> </form> Process.php if(isset($_POST['ValueAssessment'])) { $AnswerID = count($_POST['AnswerID']); $i = 0; while ($i < $AnswerID) { $AnswerID= $_POST['AnswerID'][$i]; $Value= $_POST['Value'][$i]; $QuestionID= $_POST['QuestionID'][$i]; $UserID= $_POST['UserID'][$i]; $query = "UPDATE answer SET Value = '$Value', QuestionID = '$QuestionID', UserID = '$UserID' WHERE AnswerID = '$AnswerID'"; mysql_query($query) or die ("Error in update query: $query"); ++$i; } }
  7. Hi Mate, i need help with my mysql query.. SELECT * FROM `schedules` WHERE `clientID`=''; it doesn't select any values having an empty clientID... there are rows on my database that i need to select that has an empty clientID and using this statement does not return any value... but if i use `clientID`!='' it works fine, it returns all the data having clientID. Any help is highly appreciated. Thank you in advance. Neil
  8. I am building a website about Doctor who, and I want to post various quotes from a database, when I wrote the select-query, I got the following error: Quotes Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /customers/e/a/c/doctorwhofans.be/httpd.www/test/Content/Quotes.php on line 106 (which is the one with the while expression). <?php //verbinding met de database require("./connect.php"); //select-query schrijven en uitvoeren $sql = " select * from QuotesTabel"; $result = mysql_query($sql); //alle records weergeven (terwijl er rijen gevonden worden. while ($row = mysql_fetch_assoc($result)) { //toon foto met info require("./ToonFoto.php"); } ?> Can someone help me please?
  9. Hi! i want show my project designed as a ORM that directly manipulate Database Schema aim a class as model https://github.com/Javanile/SchemaDB please give me more feedback and test reports thkx
  10. Hi, I am absolutly beginner in PHP, AJAX. In my Wordpress page I have following scene: 1. input box for name 2. combobox from country-> combo for cities depend of selected country Button for search in MySQL database After submit the database return result in a table (user, country, city, mobile, email, etc.) with 2 editable (mobile, email) input column and I put Update button in every row. My questions: 1) If I change one data on the editable column how can I know the number of row? 2) How can I run the update script without refresh page? Thanks for your answer. //UserInfo-modify.php <?php include_once('db.php'); $name = $_POST['nev']; $country = $_POST['megye']; $error = ""; $city = ""; $nodata = ""; $ID = 0; if (($country=="Bács-Kiskun")||($country=="Baranya")||($country=="Békés")||($country=="Borsod-Abaúj-Zemplén")||($country=="Csongrád")|| ($country=="Fejér")||($country=="Győr-Moson-Sopron")||($country=="Hajdú-Bihar")||($country=="Heves")||($country=="Jász-Nagykun-Szolnok")|| ($country=="Komárom-Esztergom")||($country=="Nógrád")||($country=="Pest")||($country=="Somogy")||($country=="Szabolcs-Szatmár-Bereg")|| ($country=="Tolna")||($country=="Vas")||($country=="Veszprém")||($country=="Zala")) { $city = $_POST['telepules']; if ($city=="---") $error = "-city"; } else { $error = "-country-city"; } mysqli_set_charset($conn,"utf8"); if (($city!="") AND ($name!="")) { $query = mysqli_query($conn,"SELECT nev,kor,megye,telepules,utca,mobil,email FROM `nrqadatr` WHERE nev='$name' AND telepules='$city'") or die("userinfo-modify-36 ".mysqli_error($conn));} else if (($city=="") AND ($name=="")) { $nodata = '1'; echo "Name and city = 0!"; } else if (($city!="") AND ($name=="")) { $query = mysqli_query($conn,"SELECT nev,kor,megye,telepules,utca,mobil,email FROM `nrqadatr` WHERE telepules='$city'") or die("userinfo-modify-45 ".mysqli_error($conn));} else if (($city=="") AND ($name!="")) {$query = mysqli_query($conn,"SELECT nev,kor,megye,telepules,utca,mobil,email FROM `nrqadatr` WHERE nev='$name'") or die("userinfo-modify-49 ".mysqli_error($conn));} if ($nodata!='1') { $rowcount=mysqli_num_rows($query); if ($rowcount>0) { echo '<table>'; $arrayofrows = array(); echo ' <table border=1> <tr style="background-color:#EFFBFB; font-weight:bold; border: 1px solid black;"> <td style="font-size:14px;">ID</td> <td style="font-size:14px;">Name</td> <td style="font-size:14px;">City</td> <td style="font-size:14px;">Age</td> <td style="font-size:14px;">Address</td> <td style="font-size:14px;">Mobil</td> <td style="font-size:14px;">E-mail</td> <td style="font-size:14px;">Operation</td> </tr>'; } else echo "\r\n<B><font color='red'>No data //my_script.js $("#sub").click( function() { $.post( $("#myForm").attr("action"), $("#myForm :input").serializeArray(), function(info) { $("#result").html(info); }); clearInput(); }); $("#myForm").submit( function() { return false; }); function clearInput() { $("#myForm :input").each( function() { $(this).val(''); }); } ."; while ($data = mysqli_fetch_array($query)) { $ID = $ID+1; $data_nev=$data["nev"]; echo ' <tr style="background-color:#EFFBFB; border: 1px solid black;"> <td><input type="radio" name="$kivalasztott_sor" value="AG"></td> <td style="font-size:14px;">'.$data["nev"].'</td> <td style="font-size:14px;">'.$data["telepules"].'</td> <td style="font-size:14px;">'.$data["kor"].'</td> <td style="font-size:14px;">'.$data["utca"].'</td> <td><input type="text" value='.$data["mobil"].'></td> <td><input type="text" value='.$data["email"].'></td> <td onclick="cellOnclick()"><a href="#" onclick="linkOnclick()" style="text-decoration: none;"> <input type=button value="UPDATE" myFunction(this); return false;"></button></td> </tr>'; } echo '</table>'; } unset($name); unset($kor); unset($country); unset($error); unset($city); unset($nodata); unset ($data_nev); ?> //Wordpress (main) page [insert_php] include '/select_list_cities.php'; [/insert_php] <html><head><meta charset="utf-8" /><script src="/ajax_select_cities.js" type="text/javascript"></script> </head><body><form id="myForm" action="/userInfo-modify.php" method="post"> Name*:<br><input type="text" name="nev"> <p> [insert_php] echo $re_html;[/insert_php]<br class="clear" /> <br class="clear" /> <button id="sub">Search</button> <br><br></form> <span id="result"></span> <div id="data"><?php echo $result; ?></div> <script type="text/javascript" src=" http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.1.min.js"></script> <script src="/my_script.js" type="text/javascript"></script> </body> </html>
  11. Im developing a trading card game in unity and need some help with the php and mysql side of things. My database structure is something like this. This is set up when the player registers. Each player has 60 rows inside of player_deck because the decks limit is 60. players player_id/email/password/username player_deck player_id/card_id/card_amount Now this is where I need help. Im trying to update these rows when the player saves the deck. From Unitys end im calling a URL that looks something like this. "localhost/saveplayerdata/saveplayerdeck.php?playerid=&deckcardids=&deckcardamounts=" The PHP page stores the deckcardids and deckcardamounts into two arrays. Now here is where im stuck. I need to get all the rows that belong to that player and update them with our data sent from Unity. This is what i have so far. Im able to select the rows I need but how would I go about updating them with the data in my arrays? Thanks for reading. <?php $playerId=$_GET['playerid']; $playerDeckCardIds=$_GET['deckcardids']; $playerDeckCardAmounts=$_GET['deckcardamounts']; $deckCardIds = explode(" ", $playerDeckCardIds); array_pop($deckCardIds); $deckCardAmounts = explode(" ", $playerDeckCardAmounts); array_pop($deckCardAmounts); //This is the new array of cardIds sent from Unity //foreach ($deckCardIds as $value) //{ //echo "Deck Card Id $value <br>"; //} //This is the new array of cardAmounts sent from Unity // foreach ($deckCardAmounts as $value) //{ //echo "Deck Card Amount $value <br>"; //} try { #Connect to the db $conn = new PDO('mysql:host=localhost;dbname=tcg', 'root', ''); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $conn->prepare('SELECT card_id, card_amount FROM player_deck WHERE player_id = :player_id'); $stmt->execute(array('player_id' => $playerId)); $r = $stmt->fetchAll(PDO::FETCH_OBJ); #If we have a result if ( count($r) ) { foreach($r as $row) { //echos the current database information. I need to update this data with the data inside $deckCardIds and $deckCardAmounts. echo $row->card_id; echo $row->card_amount; } } #We did not any rows that matched our id else { echo 'No match'; } } catch(PDOException $e) { echo 'ERROR: ' . $e->getMessage(); } ?>
  12. I'm failing miserably at this, but here's what I have: MariaDB [master]> describe quarters; +-------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+---------+------+-----+---------+-------+ | qtr | int(11) | NO | PRI | NULL | | +-------+---------+------+-----+---------+-------+ MariaDB [master]> describe history; +--------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------+------------------+------+-----+---------+----------------+ | historyid | int(10) unsigned | NO | PRI | NULL | auto_increment | | amount | float | NO | | NULL | | | subsidy | char(1) | NO | | NULL | | | last_payment | date | NO | | NULL | | | amount_paid | float | NO | | NULL | | | balance | float | NO | | NULL | | | attend | char(1) | NO | | N | | | attend_date | date | NO | | NULL | | | groupid | int(11) unsigned | NO | | NULL | | | clientid | int(10) unsigned | NO | MUL | NULL | | | memberid | int(10) unsigned | NO | MUL | NULL | | +--------------+------------------+------+-----+---------+----------------+ MariaDB [master]> Select clientid, last_payment, amount_paid -> From history -> WHERE YEAR(last_payment) = YEAR(CURDATE()) -> AND memberid = "1"; +----------+--------------+-------------+ | clientid | last_payment | amount_paid | +----------+--------------+-------------+ | 3 | 2016-01-26 | 100 | | 3 | 2016-10-29 | 15 | | 3 | 2016-01-30 | 15 | | 4 | 2016-01-26 | 30 | | 4 | 2016-10-29 | 30 | | 4 | 2016-01-30 | 15 | | 1 | 2016-01-26 | 15 | | 1 | 2016-10-29 | 30 | | 1 | 2016-01-30 | 100 | | 2 | 2016-01-26 | 30 | | 2 | 2016-10-29 | 30 | | 2 | 2016-01-30 | 30 | | 3 | 2016-01-28 | 100 | | 4 | 2016-01-30 | 15 | | 1 | 2016-01-30 | 100 | | 2 | 2016-01-30 | 30 | | 5 | 2016-01-29 | 30 | | 5 | 2016-02-02 | 30 | | 3 | 2016-02-02 | 15 | | 4 | 2016-02-02 | 30 | | 1 | 2016-02-02 | 15 | | 2 | 2016-02-02 | 30 | +----------+--------------+-------------+ There's returnable data from `amount_paid`, but the following query returns 0 rows. MariaDB [master]> SELECT qtr AS Quarter, SUM(amount_paid) as Total -> FROM quarters q -> LEFT JOIN history h ON qtr = QUARTER(last_payment) -> WHERE YEAR(last_payment) = YEAR(CURDATE()) -> AND memberid = "1" -> GROUP BY qtr; Empty set (0.01 sec) For the love of Mary! What am I doing wrong?
  13. Hi all, I am trying to make a list of users where two rows in a mysql database exist. My attempt so far: "SELECT * FROM mail_list INNER JOIN rosters ON mail_list.Code = rosters.Code WHERE rosters.SectorDate = '2016-01-04' AND EXISTS (SELECT * FROM rosters WHERE rosters.SectorDate = '2016-01-24' IS NOT NULL)" So basically, I want to select all the users information from mail_list table only if in the rosters table the user has a row that exists with the date 2016-01-04 and a second row 2016-01-24. I have tried several types of EXIST statements as above but no luck so far :/ Please help!! Thanks
  14. Hi Mate, I need advice on my query any inputs is highly appreciated. i have this query on the system that im developing, im using a jquery autosearch api here. $sql = 'SELECT referrals.clientid,fullname, firstname, lastname,email,referredby,hearaboutus,gatecode, address1,city,state,zip, homephone, workphone, cellphone,company FROM referrals INNER JOIN address ON address.clientid=referrals.clientid WHERE referrals.firstname is not null '; for($i = 0; $i < $p; $i++) { $sql .= ' AND fullname LIKE ' . "'%" . mysql_real_escape_string($parts[$i]) . "%' "; } My query seems making the search function slow to respond... is there any adjustments on that sql statemet that you can advice to make it search faster. im searching of about 20K of clients on my database. Thanks in advance Neil
  15. Howdy, I'm trying to get a result from my database in the proper order. CREATE TABLE IF NOT EXISTS `clc_crz_regions` ( `region_id` tinyint(2) NOT NULL, `parent_id` tinyint(2) NOT NULL DEFAULT '0', `regAbbreviation` varchar(4) NOT NULL DEFAULT '', `reg_name` varchar(40) NOT NULL DEFAULT '', ) INSERT INTO `clc_crz_regions` (`region_id`, `parent_id`, `regAbbreviation`, `reg_name`) VALUES (4, 0, 'soam', 'South America'), (1, 0, 'cari', 'Caribbean'), (20, 1, 'eaca', 'Eastern Caribbean'), (44, 1, 'soca', 'Southern Caribbean'), (21, 1, 'weca', 'Western Caribbean'), (41, 4, 'amri', 'Amazon River'); CREATE TABLE IF NOT EXISTS `clc_crz_region_groups` ( `parent_id` tinyint(2) NOT NULL, `child_id` tinyint(2)NOT NULL ) INSERT INTO `clc_crz_region_groups` (`parent_id`, `child_id`) VALUES (1, 1), (1, 20), (1, 21), (1, 44), (2, 2), (3, 3), (3, 40), (3, 57), (4, 4), I'd like it to sort by 'reg_name' for the parents, with the children under the parents also sorted by name. Caribbean Eastern Caribbean Southern Caribbean Western Caribbean South America Amazon River Cape Horn I can get the results, just can't get them to order the way I want to. SELECT r1.region_id, r1.reg_name, r1.reg_entry_name, r1.parent_id FROM $wpdb->crz_regions r1 JOIN $wpdb->crz_region_groups r2 ON r1.region_id = r2.child_id I just can't get it sorted correctly. I'd like to do it in SQL if possible. Thank you
  16. Hi all, I am trying to get information from mysql by firstly joining a couple of tables such as: "SELECT Latitude, Longitude FROM airports INNER JOIN rosters ON airports.IATA = rosters.Dep WHERE rosters.Dep = 'BGY'"; I would also however like to select another airports.Latitude and airports.Longitude in the same query. Something like... "SELECT Latitude AS departure_lat, Longitude AS depatrure_lng FROM airports INNER JOIN rosters ON airports.IATA = rosters.Dep WHERE rosters.Dep = 'BGY' AND SELECT airports.Latitude AS arrival_lat, airports.Longitude AS arrival_lng FROM airports INNER JOIN rosters ON airports.IATA = rosters.Arr WHERE rosters.Arr = 'CRL'"; So basically, I am trying to get the departure and destination latitude and longitudes from an airport where departure = BGY and arrival = CRL using one query. Thanks for any help!
  17. Ok i have a table with headings username useremail randomnumber neptune morethen5 What im trying to do is if a username has more than 5 records where neptune isnt null update the morethan5 column for all username with yes this is the query i have update ballot set morethan5 = yes where username in ( select * from ( select neptune from ballot group by username having count(1) > 5 ) x ) i got first of all an error saying yes column didnt exist so i created a new column called yes and it isnt updating any records
  18. Hello guys. I’m having trouble understanding JOIN and GROUP. I have two tables that I want to merge into one but when I try it, the result is not what is expected and I don’t know where I’m wrong. I want to merge Table A and B to get Table C as shown below: Table A Client Name Username Amount Deposited John Doe joh@doe.com 2500 Julian Cram jul@cram.com 2000 Peter Stalone pet@sta.com 1200 Creig Davies creg@davies.com 3000 Table B Client Name Username Invoice Amount John Doe joh@doe.com 1000 Julian Cram jul@cram.com 500 Peter Stalone pet@sta.com 4500 Creig Davies creg@davies.com 1500 Table C Client Name Username Invoice Amount Amount Deposited John Doe joh@doe.com 1000 2500 Julian Cram jul@cram.com 500 2000 Peter Stalone pet@sta.com 4500 1200 Creig Davies creg@davies.com 1500 3000 echo "<table width='100%' class='table table-striped tbl'>"; echo "<tr> <th bgcolor='#444444' align='center'><font color='#fff'>Client's Name</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>Username</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>Amount Deposited</font></th> </tr>"; $stmt = $pdo->query(" SELECT d.firstname, d.surname, d.username, SUM(d.amt_deposited) AS sum_deposited FROM ca_my_payments d GROUP BY d.username "); while($row = $stmt->fetch(PDO::FETCH_ASSOC)){ echo "<tr><td>"; $client = ucwords($row['firstname'] . " " .$row['surname']); echo $client; echo "</td><td>"; echo $row['username']; echo "</td><td>"; echo $row['sum_deposited']; echo "</tr></td>"; } echo "</table>"; echo "<br><br>"; echo "<table width='100%' class='table table-striped tbl'>"; echo "<tr> <th bgcolor='#444444' align='center'><font color='#fff'>Client's Name</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>Username</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>Invoice</font></th> </tr>"; $stmt = $pdo->query(" SELECT p.payee, p.username, SUM(p.total_payment) AS total_invoice FROM ca_processed p GROUP BY p.username "); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo "<tr><td>"; echo $row['payee']; echo "</td><td>"; echo $row['username']; echo "</td><td>"; echo number_format($row['total_invoice'],2); echo "</tr></td>"; } echo "</table>"; echo "<br><br>"; echo "<table width='100%' class='table table-striped tbl'>"; echo "<tr> <th bgcolor='#444444' align='center'><font color='#fff'>Client's Name</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>Username</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>Invoice</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>Amount Deposited</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>Current Balance</font></th> </tr>"; $stmt = $pdo->query(" SELECT a.payee, a.username, b.username, SUM(a.total_payment) AS total_invoice, SUM(b.amt_deposited) AS sum_deposited FROM ca_processed a LEFT JOIN ca_my_payments b ON a.username = b.username GROUP BY a.username "); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo "<tr><td>"; echo $row['payee']; echo "</td><td>"; echo $row['username']; echo "</td><td>"; echo number_format($row['total_invoice'],2); echo "</td><td>"; echo number_format($row['sum_deposited'],2); echo "</tr></td>"; } echo "</table>";
  19. I have data on a table1 on one server I need copied onto a table1 on another server that is freshly truncated. I am not getting any error output in the logs or on the screen, but no data ever appears on the second server. mysql replication is banned and no access to cli for mysqldump (this code will be hit numerous times during the day) $pdo = new PDO( 'mysql:host=' . DB_HOST_R2D2 . ';dbname=' . DB_DATABASE_DNS, DB_USER_DNS, DB_PASSWORD ); //yoda pdo settings $pdoyd = new PDO( 'mysql:host=' . DB_HOST_YODA . ';dbname=' . DB_DATABASE_DNS, DB_USER_DNS, DB_PASSWORD ); $pdoyd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdoyd->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); //records table column names $recordstbl = array('id', 'name', 'type', 'content', 'ttl', 'prio', 'change_date', 'disabled', 'ordername', 'auth'); //domain table column names $domainstbl = array('id', 'name', 'master', 'last_check', 'type', 'notified_serial', 'account'); //crypto table column names $cryptotbl = array('id', 'domain_id', 'flags', 'active', 'content'); $tblnames = array('cryptokeys', 'domains', 'records'); //loop through yoda and trunacate all 3 tables foreach($tblnames as $tbl){ $sql = 'truncate '.$tbl; $statementyd = $pdoyd->prepare($sql); $useryd = $statementyd->execute(); var_dump($statementyd); echo '<br>'; } //crazy triple loop to get sql query correct foreach($tblnames as $tbl){ if($tblnames == 'cryptokeys'){ foreach($cryptotbl as $column){ foreach ($column as $pdcolumn){ $pdcolumn = ':'.$pdcolumn; } $insert_stmt = $pdoyd->prepare("INSERT INTO ".$tbl." (".$column.") VALUES (".$pdcolumn." ON DUPLICATE KEY IGNORE"); $select_results = $pdo->query("SELECT * FROM ".$tbl); while ($row = $select_results->fetch(PDO::FETCH_ASSOC)) { $insert_stmt->execute($row); } } } if($tblnames == 'domains'){ foreach($domainstbl as $column){ foreach ($column as $pdcolumn){ $pdcolumn = ':'.$pdcolumn; } $insert_stmt = $pdoyd->prepare("INSERT INTO ".$tbl." (".$column.") VALUES (".$pdcolumn." ON DUPLICATE KEY IGNORE"); $select_results = $pdo->query("SELECT * FROM ".$tbl); while ($row = $select_results->fetch(PDO::FETCH_ASSOC)) { $insert_stmt->execute($row); } } } if($tblnames == 'records'){ foreach($recordstbl as $column){ foreach ($column as $pdcolumn){ $pdcolumn = ':'.$pdcolumn; } $insert_stmt = $pdoyd->prepare("INSERT INTO ".$tbl." (".$column.") VALUES (".$pdcolumn." ON DUPLICATE KEY IGNORE"); $select_results = $pdo->query("SELECT * FROM ".$tbl); while ($row = $select_results->fetch(PDO::FETCH_ASSOC)) { $insert_stmt->execute($row); } } } } logs (source) db1: mysql> select * from mysql.general_log; +---------------------+---------------------------------------+-----------+-----------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ | event_time | user_host | thread_id | server_id | command_type | argument | +---------------------+---------------------------------------+-----------+-----------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ | 2016-01-17 00:34:10 | root[root] @ localhost [127.0.0.1] | 7 | 1 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='nyctelecomm.com' | | 2016-01-17 00:34:10 | root[root] @ localhost [127.0.0.1] | 7 | 1 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and name='nyctelecomm.com' and domain_id=6 | | 2016-01-17 00:34:10 | root[root] @ localhost [127.0.0.1] | 7 | 1 | Query | select content from domains, domainmetadata where domainmetadata.domain_id=domains.id and name='nyctelecomm.com' and domainmetadata.kind='PRESIGNED' | | 2016-01-17 00:34:10 | root[root] @ localhost [127.0.0.1] | 7 | 1 | Query | select cryptokeys.id, flags, active, content from domains, cryptokeys where cryptokeys.domain_id=domains.id and name='nyctelecomm.com' | | 2016-01-17 00:34:11 | root[root] @ localhost [127.0.0.1] | 6 | 1 | Query | select content from domains, domainmetadata where domainmetadata.domain_id=domains.id and name='nyctelecomm.com' and domainmetadata.kind='NSEC3PARAM' | | 2016-01-17 00:34:11 | root[root] @ localhost [127.0.0.1] | 6 | 1 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='nyctelecomm.com' | | 2016-01-17 00:34:11 | root[root] @ localhost [127.0.0.1] | 6 | 1 | Query | select min(ordername) from records where ordername > '' and domain_id=6 and disabled=0 and ordername is not null | | 2016-01-17 00:34:11 | root[root] @ localhost [127.0.0.1] | 6 | 1 | Query | select ordername, name from records where ordername <= '' and domain_id=6 and disabled=0 and ordername is not null order by 1 desc limit 1 | | 2016-01-17 00:34:11 | root[root] @ localhost [127.0.0.1] | 6 | 1 | Query | select content from domains, domainmetadata where domainmetadata.domain_id=domains.id and name='nyctelecomm.com' and domainmetadata.kind='SOA-EDIT' | | 2016-01-17 00:34:11 | [powerdns] @ [108.61.175.20] | 420 | 1 | Connect | powerdns@108.61.175.20 on powerdns | | 2016-01-17 00:34:12 | powerdns[powerdns] @ [108.61.175.20] | 420 | 1 | Prepare | SELECT domain_id, name, type FROM records | | 2016-01-17 00:34:12 | powerdns[powerdns] @ [108.61.175.20] | 420 | 1 | Execute | SELECT domain_id, name, type FROM records | | 2016-01-17 00:34:12 | powerdns[powerdns] @ [108.61.175.20] | 420 | 1 | Close stmt | | | 2016-01-17 00:34:12 | powerdns[powerdns] @ [108.61.175.20] | 420 | 1 | Quit | | | 2016-01-17 00:34:13 | [powerdns] @ [108.61.175.20] | 421 | 1 | Connect | powerdns@108.61.175.20 on powerdns | | 2016-01-17 00:34:13 | powerdns[powerdns] @ [108.61.175.20] | 421 | 1 | Quit | | | 2016-01-17 00:34:19 | root[root] @ localhost [] | 411 | 1 | Query | select * from mysql.general_log | +---------------------+---------------------------------------+-----------+-----------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ 17 rows in set (0.00 sec) logs (target) db2: mysql> select * from mysql.general_log; +---------------------+--------------------------------------------+-----------+-----------+--------------+--------------------------------------------------------------------------------------------------------------------------------------+ | event_time | user_host | thread_id | server_id | command_type | argument | +---------------------+--------------------------------------------+-----------+-----------+--------------+--------------------------------------------------------------------------------------------------------------------------------------+ | 2016-01-17 00:34:15 | powerdns[powerdns] @ localhost [127.0.0.1] | 9 | 2 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='www.zippy-mail.com' | | 2016-01-17 00:34:15 | powerdns[powerdns] @ localhost [127.0.0.1] | 9 | 2 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='zippy-mail.com' | | 2016-01-17 00:34:15 | powerdns[powerdns] @ localhost [127.0.0.1] | 9 | 2 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='com' | | 2016-01-17 00:34:15 | powerdns[powerdns] @ localhost [127.0.0.1] | 9 | 2 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='' | | 2016-01-17 00:34:23 | powerdns[powerdns] @ localhost [127.0.0.1] | 8 | 2 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='nyctelecomm.com' | | 2016-01-17 00:34:25 | [powerdns] @ [108.61.175.20] | 246 | 2 | Connect | powerdns@108.61.175.20 on powerdns | | 2016-01-17 00:34:25 | powerdns[powerdns] @ [108.61.175.20] | 246 | 2 | Prepare | SELECT domain_id, name, type FROM records | | 2016-01-17 00:34:25 | powerdns[powerdns] @ [108.61.175.20] | 246 | 2 | Execute | SELECT domain_id, name, type FROM records | | 2016-01-17 00:34:25 | powerdns[powerdns] @ [108.61.175.20] | 246 | 2 | Close stmt | | | 2016-01-17 00:34:25 | powerdns[powerdns] @ [108.61.175.20] | 246 | 2 | Quit | | | 2016-01-17 00:34:26 | [powerdns] @ [108.61.175.20] | 247 | 2 | Connect | powerdns@108.61.175.20 on powerdns | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Prepare | truncate cryptokeys | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Execute | truncate cryptokeys | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Prepare | truncate domains | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Close stmt | | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Execute | truncate domains | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Prepare | truncate records | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Close stmt | | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Execute | truncate records | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Close stmt | | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Quit | | | 2016-01-17 00:34:41 | root[root] @ localhost [] | 237 | 2 | Query | select id, domain_id, name, type, content from records | | 2016-01-17 00:34:49 | root[root] @ localhost [] | 237 | 2 | Query | select * from mysql.general_log | +---------------------+--------------------------------------------+-----------+-----------+--------------+--------------------------------------------------------------------------------------------------------------------------------------+ 23 rows in set (0.00 sec)
  20. hello mate, im having problem making a search criteria work.... i have a field named fullname, inside that field i have a data eg: "Robert Williams" Im trying to use LIKE on mysql statement such as SELECT fullname FROM clients WHERE fullname LIKE '%keyword%' keyword being any character from the name "Robert Williams". but when i tried to search "Williams R" it will not show me "Robert Williams"... Then, how can i make it so that when i search for "Williams R" it will also show me "Robert Williams" What im trying to attain here is to search any name in any order whether firstname first of lastname first. Thank you in advance. Cheers! Neil
  21. Hello all. I dont know how to go about this. I have a table (Transactions) that contains transactions of users. Another table (Confirmed) contains details of every confirmed user. I want to do a select statement that will display all the confirmed user with only the last of their transaction. But so far all it does is replicate the user and their date of transaction and that is not what i want. My intention is to get something like: Firstname Surname Date Registered Last Transaction andrews john 12-12-2014 10-10-2015 doe andy 12-12-2010 12-12-2014 But i'm getting something like: Firstname Surname Date Registered Last Transaction andrews john 12-12-2014 10-10-2015 andrews john 12-12-2014 10-11-2015 doe andy 12-12-2010 12-12-2014 doe andy 12-12-2010 01-12-2014 doe andy 12-12-2010 12-12-2013 Thanks $stm=$pdo->query("select * from confirmed left join transaction on confirmed.user_id = transaction.user_id where confirmed.status='confirmed' order by date"); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo $row['firstname']; echo $row['surname']; echo $row['regDate']; echo $row['lastTrans']; }
  22. I am using a barebones script listed as a members area but all it does is give me login and secure pages using the auth.php (code listed below) since I got the script I have added a new column 'Rank' to the database table 'members' with this rank there are 4 ranks: Guest Blocked/Banned Helpers Administration The new page I am creating I want it to use this rank system I added, ranks 3 and 4 get access, rank 2 I want to redirect to my 403 Access Forbidden located at my main site 'bullwebhost.co.uk/error.php?cmd=403' , rank 1 gets a message shown saying 'Welcome Guest print '$_SERVER["REMOTE_ADDR"]; , You have tried accessing a Restricted Area Your IP print '$_SERVER["REMOTE_ADDR"]; has been logged and Webmaster Informed (if possible via phpmail as i cant use smtp) of your accessing this area. Now For the code auth.php //Start session session_start(); //Check whether the session variable SESS_MEMBER_ID is present or not if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) { header("location: access-denied.php"); exit(); } Database Structure CREATE TABLE IF NOT EXISTS `members` ( `member_id` int(11) unsigned NOT NULL AUTO_INCREMENT, `Rank` int(11) NOT NULL DEFAULT '1', `firstname` varchar(100) DEFAULT NULL, `lastname` varchar(100) DEFAULT NULL, `login` varchar(100) NOT NULL DEFAULT '', `passwd` varchar(32) NOT NULL DEFAULT '', PRIMARY KEY (`member_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; config.php <?php define('DB_HOST', '****'); define('DB_USER', '****'); define('DB_PASSWORD', '****'); define('DB_DATABASE', '***'); ?> Restricted File require_once('auth.php'); include 'config.php'; $conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(! $conn ) { die('Could not connect: ' . mysql_error()); } $sql = 'SELECT Rank FROM members WHERE Rank="3" or Rank="4"'; mysql_select_db(DB_DATABASE); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Could not get data: ' . mysql_error()); } while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) { print ' <!DOCTYPE html PUBLIC "-//W3C//DTD(I have code for this part) 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=iso-8859-1" /> <title>My Profile</title> <link href="loginmodule.css" rel="stylesheet" type="text/css" /> </head> <body> <h1>My Profile </h1> <a href="member-index.php">Home</a> | <a href="logout.php">Logout</a> <p>This is another secure page. </p> </body> </html>'; } Attempts Okay I did a more detailed (I think) search and came across something but it didn't work my edited code is below $sql = mysql_query("SELECT * FROM members WHERE Rank ='3 or 4' AND member_id ='".$_SESSION['SESS_MEMBER_ID']); Code Removed else { (redirect to error document) mysql_close($conn); } That is all I changed in the Restricted File code above. I still am not getting errors printed I have php errors in htaccess and using the trigger but still blank white screen Trying to get my question across (not very easy for me), I am trying to make a page (not giving name of file) that using the auth and config files to do a check for the users rank is either 3 or 4 user gets access, 1 print message 2 redirect to 403 document (easiest way possible) so that even if someone tries to bypass any security in place they still need to be rank 3 or 4 to even see the page contents. Also possible long shot but what would be the best way to block IP addresses would php and mysql/mysqli (don't know PDO, willing to learn mysqli) or would it be better to use .htaccess for the reason being I wanting to block Loads of IPS but want adding them to be easy and also using my new pages was looking at building forms to add entries, remove entries Viewing the list, (I have code for this part). What I asking is would I be better of using php and mysql/i or .htaccess because some of the ips are wildcard ips to be banned and redirected to my error document. Kind regards Harry Smith
  23. I have the following UNION query that works. I need this same thing so that I don't have to UNION fifty two times to get the weekly results for a year. Attached is the DB Import Dump, Current Query Result, The desired output, and a chart graphic of what I am looking to end up with. Current data is only going to give three results. Should just have zero count for all other weeks with no data. SELECT Count(l.lot_id) AS slab_count, WEEK ('2015-01-04') AS week_number FROM lot l LEFT JOIN block AS b ON l.block_id = b.block_id LEFT JOIN community AS c ON b.community_id = c.community_id WHERE l.dried_in_date IS NULL AND l.slab_date <= '2015-01-10' AND (c.contract_type_id = 1 OR c.contract_type_id= 3) OR l.slab_date <= '2015-01-10' AND l.dried_in_date >= '2015-01-04' AND (c.contract_type_id = 1 OR c.contract_type_id= 3) UNION /* WEEK 2 */ SELECT Count(l.lot_id) AS slab_count, WEEK ('2015-01-11') AS week_number FROM lot l LEFT JOIN block AS b ON l.block_id = b.block_id LEFT JOIN community AS c ON b.community_id = c.community_id WHERE l.dried_in_date IS NULL AND l.slab_date <= '2015-01-17' AND (c.contract_type_id = 1 OR c.contract_type_id= 3) OR l.slab_date <= '2015-01-17' AND l.dried_in_date >= '2015-01-11' AND (c.contract_type_id = 1 OR c.contract_type_id= 3) UNION /* WEEK 3 */ SELECT Count(l.lot_id) AS slab_count, WEEK ('2015-01-18') AS week_number FROM lot l LEFT JOIN block AS b ON l.block_id = b.block_id LEFT JOIN community AS c ON b.community_id = c.community_id WHERE l.dried_in_date IS NULL AND l.slab_date <= '2015-01-24' AND (c.contract_type_id = 1 OR c.contract_type_id= 3) OR l.slab_date <= '2015-01-24' AND l.dried_in_date >= '2015-01-18' data.sql.txt
  24. Hi I got a column in my database containing profile information in an array form, but I want to select a specific part the gender of the person from the column and count the males and female values My database column contains the value en,ZA,1991-01-30,Male,1 I know I can explode the values like this $str = explode(',', $query); $answ = $str[3]; but I don't know how to implement it for the database to count the amount of values named Male and Female
  25. I am trying to set a column equal to the column in another table where the date matches. I seem to have a problem in my query and I have tried multiple methods. Can someone tell me where the mistake is? $query2 = "UPDATE a SET a.CalDatePrice = b.Close FROM ". $symbol ." b INNER JOIN CleanedCalendar a ON a.BuyDate = b.Date"; 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 'FROM CLBS b INNER JOIN CleanedCalendar a ON a.BuyDate = b.Dat' at line 3
×
×
  • 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.