Stancobridge
-
Posts
8 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by Stancobridge
-
-
17 hours ago, Don E said:
You can try checking out the SUBSTR MySQL function(s). https://www.w3schools.com/sql/func_mysql_substr.asp
Thanks, but the tutorial is about selecting some substring from a string but what I want to select paragraph
-
Hello,
I have a variable ($post) that contains posted content from database. Now I want to select the first paragraph and insert a code after it (Ads precisely ).
Here is my code
<?php include "../modules/gfuncs.php"; $topicId=(int)$_GET['id']; #check if topic exists $q=$conn->query("SELECT * FROM topics WHERE id='$topicId'") or die( $conn->error ); if(mysqli_num_rows($q)==0){ header("location: $thisDomain/notfound"); exit; } #check for post $c4p=$conn->query("SELECT * FROM posts WHERE topicid=$topicId") or die($conn->error); if(mysqli_num_rows($c4p)==0){ $delpost=$conn->query("DELETE FROM topics WHERE id=$topicId") or die($conn->error); header("location:$thisDomain/notfound"); exit; } #new comment $notify=""; $err=""; if(isset($_POST['post']) and isLoggedIn()){ $msg=$_POST['msg']; $fid=(int)$_POST['fid']; $thisdate=time(); $error=array(); #if user uploads attachment if($_FILES['attach']['size']>0){ $thumb=$_FILES['attach']; $thumbtmp=$thumb['tmp_name']; $thumbname=$thumb['name']; $thumbsize=$thumb['size']; $targetDir="thumbs/$thumbname"; $ext=pathinfo($targetDir, PATHINFO_EXTENSION); $allowed=array("jpg","gif","png"); if(!in_array($ext, $allowed)){ $error[]="Invalid thumbnail format"; } elseif($thumbsize > 2097152){ $error[]="Thumbnail size exceeded limit"; } } if(!$msg or empty($msg)){ $error[]="Please enter a comment"; } elseif( strlen($msg)<3){ $error[]="Comment too short"; } if(count($error)==0){ $newAttachName=""; if($_FILES['attach']['size']>0){ $newAttachName=encrypt(time()*rand(), 15).".jpg"; @move_uploaded_file($thumbtmp, "thumbs/$newAttachName"); } $save=$conn->query("INSERT INTO posts SET topicid=$topicId, forumid=$fid, poster='$curUser', postdate=$thisdate, post='$msg', attachment='$newAttachName'") or die($conn->error); $notify='<div class="successHolder">Comment Successfully Added!</div>'; } else { $err=implode(",<br>", $error); $notify='<div class="errorHolder">'.$err.'</div>'; } } $load=mysqli_fetch_object($q); $forumid=$load->forumid; $subject=_read($load->subject); $subjext=$load->subject; $poster=$load->poster; $views=$load->views; #update views $newviews=$views+1; $updviews=$conn->query("UPDATE topics SET views=$newviews WHERE id=$topicId") or die($conn->error); $postdate=$load->postdate; $postdate=date("d, M Y.", $postdate); $lastposter=$load->lastposter; $lastpostdate=$load->lastpostdate; $locked=$load->locked; $attachment=$load->attachment; #load forum info $fq=$conn->query("SELECT * FROM forums WHERE forumid=$forumid") or die($conn->error); $ft=mysqli_fetch_object($fq); $forumName=$ft->forumname; $forumUrl="$thisDomain/forum/$forumid/".urlize($forumName); #count posts $postCount=$conn->query("SELECT * FROM posts WHERE topicid=$topicId") or die( $conn->error); $totalPosts=mysqli_num_rows($postCount); #pagination $limit=13; $pagination= new paging; $pagination->totalResults($totalPosts); $pagination->rows_per_page($limit); $page=@$_GET['page']; $pagination->page($page); $pagination->thisPage("$thisDomain/forum/$forumid/topic/$topicId/".urlize($subjext)); $paging=$pagination->paging(); $paging.="<span class=\"tp\">Page ".$pagination->currentPage()." of ".$pagination->totalPages()."</span>"; $anotif=""; $adminMenu=""; if($isAdmin){ if(isset($_POST['adminAct'])){ $time=time(); $act=$_POST['admin_act']; if($act=="tag_topic"){ $qt=$conn->query("SELECT * FROM updates WHERE media='topic' AND media_id='$topicId'") or die($conn->error); if(mysqli_num_rows($qt)==0){ $qaa=$conn->query("INSERT INTO updates SET media='topic', media_id=$topicId, updatetime=$time") or die($conn->error); $anotif='<div class="successHolder">Topic successfully tagged to homepage</div>'; } else { $anotif='<div class="errorHolder">Topic is already in updates</div>'; } } elseif($act="untag_topic"){ $qaa=$conn->query("DELETE FROM updates WHERE media='topic' AND media_id=$topicId") or die($conn->error); $anotif='<div class="successHolder">Topic successfully removed from updates</div>'; } elseif($act=="del_topic"){ $qaa=$conn->query("DELETE FROM topics WHERE id=$topicId") or die($conn->error); $delPost=$conn->query("DELETE FROM posts WHERE topicid=$topicId") or die($conn->error); $delFromUpdates=$conn->query("DELETE FROM updates WHERE media='topic' AND media_id=$topicId") or die($conn->error); header("location:$thisDomain/forum"); exit; } elseif($act=="edit_topic"){ header("location:$thisDomain/forum/topiceditor"); exit; } } $adminMenu="<div class=\"ContentX\"><form method=\"post\" action=\"\">"; #TAGGING: check if topic is tagged or not $qt=$conn->query("SELECT * FROM updates WHERE media='topic' AND media_id='$topicId'") or die($conn->error); if(mysqli_num_rows($qt)==0){ $adminMenu.=" <input type=\"radio\" name=\"admin_act\" value=\"tag_topic\"> Tag Topic"; } else { $adminMenu.=" <input type=\"radio\" name=\"admin_act\" value=\"untag_topic\"> Untag Topic"; } $adminMenu.=" <input type=\"radio\" name=\"admin_act\" value=\"del_topic\"> Delete Topic"; $adminMenu.=" <input type=\"radio\" name=\"admin_act\" value=\"edit_topic\"> Edit Topic <button type=\"submit\" name=\"adminAct\" class=\"w3-btn\">Submit</button></form></div>"; } #resend query to initiate paging $postQ=$conn->query("SELECT * FROM posts WHERE topicid=$topicId ORDER BY id ASC LIMIT $pagination->offset,$pagination->rows_per_page") or die($conn->error); #load all posts $contents=""; $postMenu=""; while($loadp=mysqli_fetch_object($postQ)){ $postid=$loadp->id; $poster=$loadp->poster; $postdate=$loadp->postdate; $postAttach=$loadp->attachment; $post=""; if($postAttach){ $post='[img]'.$thisDomain.'/forum/thumbs/'.$postAttach.'[/img]'; } $post.=$loadp->post; $post=_bbcode(_read($post)); #get user info $usr=new userinfo; $usr->user($poster); $posterDP=$usr->get_info("dp"); $posterCity=$usr->get_info("city"); $posterState=$usr->get_info("state"); $postdate=date("g:ia, jS M Y.", $postdate); if($isAdmin){ $postMenu="\n<br>[<a href=\"$thisDomain/forum/editpost/$postid\">Edit Post</a>] / [<a href=\"$thisDomain/forum/delpost/$postid\">Delete Post</a>]"; } $contents.=<<<eof <div class="aPost"> <table class="info"> <tr> <td width="75"> <img src="$thisDomain/user/dps/$posterDP" height="70" width="70" id="infoDP"> </td> <td> <a href="$thisDomain/profile/$poster"><span class="fa fa-user"></span> $poster</a>. $posterCity, $posterState<br> <span class="fa fa-pencil"></span> $postdate </tr> </table> <div class="msgBody"> $post </div>$postMenu </div> eof; } $pageTitle=$subject; include "../header.php"; ?>
-
thanks, I will try dat
-
Hello everyone!
Am having problem with the youtube grabber I uploaded in my site. The first time I uploaded it on my host it worked well but later stopped. All I see is
Warning: Invalid argument supplied for foreach() in.... on line 13
but later it disappeared and started working well yesterday night the grabber didn't work at all, when am about to make this post I wish to post the screenshort but going to my site to screenshort it I found out that the grabber has started working normal again. Am tired of all this partial contact in the please because I know that very soon it will stop again.
Here is the php script of homepage that it do occur
<?php include "conf.php"; include "header.php"; $fetchURI="https://www.googleapis.com/youtube/v3/search?type=video&q=bollywood&key=$api_key∂=snippet&maxResults=24"; $ch=curl_init($fetchURI); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $data=curl_exec($ch); curl_close($ch); $datas=json_decode($data); $sdata=""; $fetch_data=$datas->items; foreach($fetch_data as $vid){ $vidId=$vid->id->videoId; $thumb_uri=$vid->snippet->thumbnails->medium->url; $title=$vid->snippet->title; $time=strtotime($vid->snippet->publishedAt); $date=date("jS, F Y", $time); $sdata.=' <div class="v-item"> <div class="pplay"> <a href="'.$base.'/view/'.$vidId.'.html"><span class="fa fa-play"></span></a> </div> <img src="'.$thumb_uri.'"> <a href="'.$base.'/view/'.$vidId.'.html">'.$title.'</a> <div class="time-in"><span class="fa fa-clock-o"></span> '.$date.'</div> </div>'; } ?> <div class="w3-row v-cont" id="fsts"> <div class="w3-row w3-padding w3-margin"> <div class="w3-left"> <h1>Newest Videos</h1> </div> </div> <?=$sdata?> </div> <?php include "footer.php"; ?>
-
am having this invalid argument supplied for foreach in my site will post it tomorrow am not close to the code now...hope u guys will help
-
thanks bro...but I need more light on this
-
Hello everyone, am new here and I believe that am going to get more help in this wonderful community...
Since am a beginner in web programming. I started with Javascript, on learning it I got stucked in String. Where we have Constructor, Prototype and Length.
I understood others but am still getting confused on Prototype.
I didn't understand really what they are trying to teach. I know it is used to add a new value to an object.
But the question is how? How can we use the added value? Where can we use it.
Please I need help on this..am waiting in anticipation. Thanks
How Can Select First Paragraph select in a Post
in PHP
Posted
Alright thanks dudes...let apply this