-
Posts
530 -
Joined
-
Last visited
Everything posted by lovephp
-
what wrong am i doing here anyone? if($_SERVER["REQUEST_METHOD"] == "POST") { $ne_title = $_POST['ne_title']; $ne_description = $_POST['ne_description']; $ne_keyword = $_POST['ne_keyword']; if($_POST['ne_youtube'] ==''){ $ne_youtube = ''; }else{ $ne_youtube = $_POST['ne_youtube']; } $ne_youtube = $_POST['ne_youtube']; $ne_article = $_POST['ne_article']; $date=date("Y/m/d"); $url=''.create_slug($ne_title).'.php'; if($_FILES['file']['name']!='') { $tmp_name = $_FILES["file"]["tmp_name"]; $namefile = $_FILES["file"]["name"]; $ext = end(explode(".", $namefile)); $fileUpload = move_uploaded_file($tmp_name,"../uploads/images/".$image_name); $image_name=time().".".$ext; watermark_image($tmp_name,"../uploads/images/".$image_name); $img = ''.$image_name.''; }else{ $img = ''; } /*mysql_query("INSERT INTO article (`ne_title`,`ne_keyword`,`ne_description`,`ne_image`,`ne_youtube`,`ne_article`,`ne_url`) VALUES ('$ne_title','$ne_keyword','$ne_description','$img','$ne_youtube','$ne_article','$url')") or exit('<p align="center"><font color="red" size="5">Error:</font> Database not found.</p>');*/ $qry1 = "INSERT INTO article (ne_title, ne_keyword, ne_description, ne_image, ne_youtube, ne_article, ne_url) VALUES (:ne_title, :ne_keyword, :ne_description, :ne_image, :ne_youtube, :ne_article, :ne_url)"; $stmt = $db->prepare($qry1); $stmt->bindParam(':ne_title', $ne_title); $stmt->bindParam(':ne_keyword', $ne_keyword); $stmt->bindParam(':ne_description', $ne_description); $stmt->bindParam(':ne_image', $img); $stmt->bindParam(':ne_youtube', $ne_youtube); $stmt->bindParam(':ne_article', $ne_article); $stmt->bindParam(':ne_url', $url); $stmt->execute(); // $id = mysql_insert_id(); // mysql_query("UPDATE article SET ne_url='news-events/".$id."/".$url."' WHERE id ='".$id."'"); $id = $db->lastInsertId(); $seturl = "news-events/".$id."/".$url.""; $qry2 = "UPDATE article SET ne_url = :ne_url WHERE id = :id"; $stm = $db->prepare($qry2); $stmt->bindParam(':ne_url', $seturl); $stmt->bindParam(':id', $id); $stm->execute(); echo ('<meta http-equiv="refresh" content="1;url=post-article.php?id='.$id.'">'); } } the error i get is Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: no parameters were bound' in C:\wamp\www\web\post-article.php:139 Stack trace: #0 C:\wamp\www\web\post-article.php(139): PDOStatement->execute() #1 {main} thrown in C:\wamp\www\web\post-article.php on line 139 and if i try to upload image in the post i get this Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'ne_youtube' cannot be null' in C:\wamp\www\web\\post-article.php:129 Stack trace: #0 C:\wamp\www\web\post-article.php(129): PDOStatement->execute() #1 {main} thrown in C:\wamp\www\web\post-article.php on line 129
-
SQLSTATE[42000]: Syntax error or access violation: 1064
lovephp replied to lovephp's topic in MySQL Help
agreed -
SQLSTATE[42000]: Syntax error or access violation: 1064
lovephp replied to lovephp's topic in MySQL Help
help fix plz bro -
if there is no records in my table then im getting this error on the page' SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-5' at line 1 how could i fix this anyone? my php par is here try { require_once 'db.php'; $total = $db->query('SELECT COUNT(*) FROM article')->fetchColumn(); $per_page = 5; $pages = ceil($total / $per_page); $page = min($pages, filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT, array( 'options' => array( 'default' => 1, 'min_range' => 1, ), ))); $offset = ($page - 1) * $per_page; $start = $offset + 1; $end = min(($offset + $per_page), $total); $stmt = $db->prepare('SELECT * FROM article ORDER BY ne_title LIMIT :limit OFFSET :offset'); $stmt->bindParam(':limit', $per_page, PDO::PARAM_INT); $stmt->bindParam(':offset', $offset, PDO::PARAM_INT); $stmt->execute(); if ($stmt->rowCount() > 0) { $stmt->setFetchMode(PDO::FETCH_ASSOC); $iterator = new IteratorIterator($stmt); foreach ($iterator as $row) { $desc = $row["ne_article"]; $img = $row['ne_image']; if(!empty($img)){ $img = '<br/><img src="uploads/images/'.$img.'" alt="" class="responsive-shrink">'; }else{ $img = ''; } $youtube = $row["ne_youtube"]; if(!empty($youtube)){ $youtube = '<br/><div class="video-container"><iframe src="http://www.youtube.com/embed/'.$youtube.'"></iframe></div>'; }else{ $youtube = ''; } echo '<h4><a href="'.$row['ne_url'].'">'.$row['ne_title'].'</a></h4> <h5><b>Views:</b> '.$row['views'].', <b>Posted on:</b> '.format_date($row['created']).'</h5> '.$img.' '.$youtube.' <p> <br/>'.bbcode(nl2br(shortenString($desc))).' </p> <div id="pagelink"> <a href="'.$row['ne_url'].'" class="myButton"> Read more...</button></a> </div>'; } echo '<div id="pagination"> <div id="pagiCount">'; $prevlink = ($page > 1) ? '<span id="prev"><a href="?page=1" title="First page">First</a></span> <span id="prev"><a href="?page=' . ($page - 1) . '" title="Previous page"><<</a></span>' : ''; $nextlink = ($page < $pages) ? '<span id="next"><a href="?page=' . ($page + 1) . '" title="Next page">>></a></span> <span id="next"><a href="?page=' . $pages . '" title="Last page">Last</a></span>' : ''; echo '<div id="paging"><p><small>', $prevlink, ' Page ', $page, ' of ', $pages, '', $nextlink, '</small></p></div>'; echo '</div> </div>'; } else { echo '<p>No resilts found.</p>'; } } catch (Exception $e) { echo '<p>', $e->getMessage(), '</p>'; }
-
did it thanks a ton
-
still not getting it how to get it into my codes
-
not getting it bro
-
how do i do this someone? here is my code what is want is if there is just just one image then it display as the code below <?php $stm = $db->prepare("SELECT * FROM images WHERE id = '".$id."'"); $stm->execute(); $rs = $stm->fetchAll(); foreach( $rs as $img ) { ?> <div style="display: inline-block;"> <img src="uploads/images/<?php echo $img['img']; ?>" class="fancybox"/> </div> <?php } ?> if more than 1 record than only the first image will be in <div style="display: inline-block;"><img src="uploads/images/<?php echo $img['img']; ?>" class="fancybox"/></div> and rest will be inside just <div><img src="uploads/images/<?php echo $img['img']; ?>" class="fancybox"/> </div> <div><img src="uploads/images/<?php echo $img['img']; ?>" class="fancybox"/> </div> <div><img src="uploads/images/<?php echo $img['img']; ?>" class="fancybox"/> </div> <div><img src="uploads/images/<?php echo $img['img']; ?>" class="fancybox"/> </div> without the style="display: inline-block;" from 2nd record onwards
-
how to fetch images from images table and display along with topic?
lovephp replied to lovephp's topic in MySQL Help
thanks bro works -
ok so i got one table as topic and one is images now im trying to display the topic which is displaying ok but how do i get the images matching the topic id? the image table has rows like id tid img_name $stmt = $db->prepare("SELECT * FROM topic"); $stmt->execute(); $rs = $stmt->fetchAll(); foreach( $rs as $trs ) { echo $trs['topic_name']; }
-
could someone fix this for me please by slider is working just ok but 2 silders in same page is conflicting, my albums are dynamically fetch from db so how to not make it conflict please https://jsfiddle.net/x217hseb/15/ really appreciate your time and help
-
converting my old script to PDO results do not show?
lovephp replied to lovephp's topic in PHP Coding Help
in error logs i find nothing related to this but yes i found this yes that is_resource($result) is previous code how on earth i deal with the pagination without that? [Tue Mar 15 01:50:40 2016] [error] [client 127.0.0.1] PHP Parse error: parse error in C:\\wamp\\www\\web\\article.php on line 24, referer: http://localhost/web/news-events.php -
converting my old script to PDO results do not show?
lovephp replied to lovephp's topic in PHP Coding Help
oops sorry corrected it * but still i only get is the paging number not the data, nothing is displaying from article table -
can someone tell me why the results are not displaying? <?php require_once 'db/_db.php'; $stmt = $db->prepare("SELECT ^ FROM article"); $stmt->execute(); $result = $stmt->fetchAll(); $total_rows = $stmt->rowCount(); //$allRecords = mysql_query('select * from article'); //$total_rows = mysql_num_rows($allRecords); //$base_url = 'https://localhost/pagi/'; // global $per_page; $num_links = 4; $total_rows = $total_rows; $cur_page = 1; if(isset($_GET['page'])) { $cur_page = $_GET['page']; $cur_page = ($cur_page < 1)? 1 : $cur_page; //if page no. in url is less then 1 or -ve } $offset = ($cur_page-1)*$per_page; //setting offset $pages = ceil($total_rows/$per_page); $start = (($cur_page - $num_links) > 0) ? ($cur_page - ($num_links - 1)) : 1; $end = (($cur_page + $num_links) < $pages) ? ($cur_page + $num_links) : $pages; //$res = mysql_query("SELECT * FROM article ORDER BY id DESC LIMIT ".$per_page." OFFSET ".$offset); $stm = $db->prepare("SELECT * FROM article ORDER BY id DESC LIMIT ".$per_page." OFFSET ".$offset); $stm->execute(); $res = $stm->fetchAll(); $rows = $stm->rowCount(); if($rows < 1){ header("Location: news-events.php"); exit; } if(is_resource($result)) { foreach( $res as $row ) { $desc = $row["ne_article"]; $img = $row['ne_image']; if(!empty($img)){ $img = '<br/><img src="uploads/images/'.$img.'" alt="" class="responsive-shrink">'; }else{ $img = ''; } $youtube = $row["ne_youtube"]; if(!empty($youtube)){ $youtube = '<br/><div class="video-container"><iframe src="http://www.youtube.com/embed/'.$youtube.'"></iframe></div>'; }else{ $youtube = ''; } //shortenString($row['ne_article']); ?> <h4><a href="<?php echo $row['ne_url']; ?>"><?php echo $row['ne_title']; ?></a></h4> <h5><b>Views:</b> <?php echo $row['views']; ?>, <b>Posted on:</b> <?php echo format_date($row['created']); ?></h5> <?php echo $img; ?> <?php echo $youtube; ?> <p> <br/><?php echo bbcode(nl2br(shortenString($desc))); ?> </p> <div id="pagelink"> <a href="<?php echo $row['ne_url']; ?>" class="myButton"> Read more...</button></a> </div> <?php } } ?> <div id="pagination"> <div id="pagiCount"> <br/><br/> <?php if(isset($pages)) { if($pages > 1) { if($cur_page > $num_links) // for taking to page 1 // { $dir = "First"; echo '<span id="prev"> <a href="'.$_SERVER['PHP_SELF'].'?page='.(1).'">'.$dir.'</a> </span>'; } if($cur_page > 1) { $dir = "Prev"; echo '<span id="prev"> <a href="'.$_SERVER['PHP_SELF'].'?page='.($cur_page-1).'">'.$dir.'</a> </span>'; } for($x=$start ; $x<=$end ;$x++) { echo ($x == $cur_page) ? '<strong>'.$x.'</strong> ':'<a href="'.$_SERVER['PHP_SELF'].'?page='.$x.'">'.$x.'</a> '; } if($cur_page < $pages ) { $dir = "Next"; echo '<span id="next"> <a href="'.$_SERVER['PHP_SELF'].'?page='.($cur_page+1).'">'.$dir.'</a> </span>'; } if($cur_page < ($pages-$num_links) ) { $dir = "Last"; echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$pages.'">'.$dir.'</a> '; } } } ?>
-
how to email checkbox values without multiple emails?
lovephp replied to lovephp's topic in PHP Coding Help
ok never mind found a solution which is $room = nl2br(implode(',', $_POST['room'])); -
ok so m stuck here not getting what to do, the email i want to sent it as example Dear Management, ABCD XYZ would like to book the following rooms Room No. 101 Room No. 102 Room No. 103 From: 2016-03-16 to: 2016-03-21 but with my code everything is looping and sending multiple emails, now to get foreach values inside the mail body without looping and send just one email with the number of room user selects from checkbox? $room = $_POST['room'] = <input type="checkbox" name="room[]" value="<?php echo $roomid; ?>" /> <?php echo $roomname; ?> if(isset($_POST['submit'])){ $room = $_POST['room']; $checkin = trim($_POST['checkin']); $checkout =trim($_POST['checkout']); $name = trim($_POST['name']); $phone = trim($_POST['phone']); $email = trim($_POST['email']); foreach($room as $rooms) { $rval = 'Room No.: '.$rooms.'<br/>'; } $headers = "From: Someone <someemail@somemail.com>\r\n"; $headers .= "Reply-To :$from\r\n"; $headers .= "Return-Path: someemail@somemail.com\r\n"; $headers .= 'MIME-Version: 1.0' . "\n"; $headers .= 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'Content-type: text/html; charset=us-ascii' . "\r\n"; 'X-Mailer: PHP/' . phpversion(); $message = " "; mail($to, $subject, $message, $headers); }
-
how would i query these tables for availables for room reservation
lovephp replied to lovephp's topic in PHP Coding Help
kind of getting it now thanks alot for he help bro really appreciate it. -
how would i query these tables for availables for room reservation
lovephp replied to lovephp's topic in PHP Coding Help
what is still confusing me is that we are comparing the checkin date with the checkout date from form -
how would i query these tables for availables for room reservation
lovephp replied to lovephp's topic in PHP Coding Help
cool so now is my query correct? -
how would i query these tables for availables for room reservation
lovephp replied to lovephp's topic in PHP Coding Help
is this what you mean? WHERE checkin < '".$to."' AND checkout > '".$from."' but say i got a booking on room id 1 from 2016-03-12 to 2016-03-15 and in form i select checkin from date 12 and checkout date on 16 shouldn't that room be available then? this is really confusing me like hell sorry for eating up ur head too -
how would i query these tables for availables for room reservation
lovephp replied to lovephp's topic in PHP Coding Help
Help correct please. -
how would i query these tables for availables for room reservation
lovephp replied to lovephp's topic in PHP Coding Help
ok so i created two fields as `checkin` date NOT NULL, `checkout` date NOT NULL, checkin 2016-03-15 checkout 2016-03-20 and the query im using is $sql = mysql_query("SELECT * FROM rooms WHERE name = '".$room_type."' AND id NOT IN (SELECT room_id FROM reservations WHERE checkin < '".$from."' AND checkout > '".$to."')") or die(mysql_error()); and in my rooms table there are 8 rooms by the name Deluxe, 8 Executive Rooms and when i do a search on the dates above and room name Deluxe and echo mysql_num_rows($sql); it returns 8 whereas it should show 7 and if i do it as <= '".$from."' AND checkout >= '".$to."' then it returns 7 now what wrong am i doing? -
how would i query these tables for availables for room reservation
lovephp replied to lovephp's topic in PHP Coding Help
sorry here is the code something is definitely wrong because im not getting desired results $sql = mysql_query("SELECT * FROM rooms WHERE name LIKE '%".$room_type."%' AND id NOT IN (SELECT room_id FROM reservations WHERE start < '".$from."' AND end > '".$to."')") or die(mysql_error()); my start and end date structure in db is like `start` datetime DEFAULT NULL, `end` datetime DEFAULT NULL, -
how would i query these tables for availables for room reservation
lovephp replied to lovephp's topic in PHP Coding Help
ok so what is wrong in this query of mine that no results are showing? $from = $_REQUEST['from']; $to = $_REQUEST['to']; $room_type = $_REQUEST['room_type']; $sql = mysql_query("SELECT * FROM rooms WHERE name LIKE '%".$room_type."%' id NOT IN (SELECT room_id FROM reservations WHERE start < '".$from."' AND end > '".$to."'") or die(mysql_error()); m getting syntax error but am not understanding whats going wrong -
how would i query these tables for availables for room reservation
lovephp replied to lovephp's topic in PHP Coding Help
the status in reservations table is like new, confirmed etc type of status and the status in rooms is for whether its clean drit etc.