jcbones
Staff Alumni-
Posts
2,653 -
Joined
-
Last visited
-
Days Won
8
Everything posted by jcbones
-
I would suggest that you contact the people who sold it to you. They could likely fix it up with a line or two. While we would be floundering with code that we don't have, unless you buy each of us a copy.
-
After 2 more minutes of thought! The stories still appear on the original format that you posted. There is no need to change anything YET. It hasn't been implemented on the server YET.
-
Your class takes http://api.worldnow.com/feed/v2.0/categories/181615/stories and parses the story id's from it. Then it changes {story_id} in http://www.khq.com/category/{story_id}/local-news?clienttype=rss, with the story id retrieved from the previous url, and gets the contents of that page, and echo's it back to your client. So either http://api.worldnow.com/feed/v2.0/categories/181615/stories is wrong, or http://www.khq.com/category/{story_id}/local-news?clienttype=rss isn't set up to parse the data like this yet! PS. When I grab an id from the first URL, and pass it to the second URL via the suggested format, I get a "The requested page is temporarily unavailable"
-
I would think you could change this line: var $full_story_url = 'http://www.khq.com/Global/story.asp?S={story_id}&clienttype=rssstory'; to var $full_story_url = 'http://www.khq.com/category/{story_id}/local-news?clienttype=rss'; And it should work.
-
It tells the database to escape the data, then drop the slashes when it enters the text. This will leave the text in the database, just like it was entered, all the while slightly protecting you from injection attacks. For instance try inserting this string into your database with and without the mysqli_real_escape_string(). ' OR ' You will find vast differences in the actions of the database. Note, in an edit situation, this will simple input the string into the database with the function. Without the function will trigger an error, that will allow for someone to further manipulate you database, because they now have a table name and a column names (if your errors are sent to the page output).
-
How do I include a resizing script to my existing script?
jcbones replied to frank_solo's topic in PHP Coding Help
Try this: May not work the first time around cause it is UN-TESTED! <?php session_start(); error_reporting(E_ALL); ini_set('display_errors','On'); include('SimpleImage.php'); $image = new SimpleImage(); //error_reporting(E_ALL); // image upload folder $image_folder = 'images/classified/'; // fieldnames in form $all_file_fields = array('image1', 'image2' ,'image3', 'image4'); // allowed filetypes $file_types = array('jpg','gif','png'); // max filesize 5mb $max_size = 5000000; //echo'<pre>';print_r($_FILES);exit; $time = time(); $count = 1; foreach($all_file_fields as $fieldname){ if($_FILES[$fieldname]['name'] != ''){ $type = substr($_FILES[$fieldname]['name'], -3, 3); // check filetype if(in_array(strtolower($type), $file_types)){ //check filesize if($_FILES[$fieldname]['size']>$max_size){ $error = "File too big. Max filesize is ".$max_size." MB"; }else{ // new filename $filename = str_replace(' ','',$myusername).'_'.$time.'_'.$count.'.'.$type; // move/upload file $image->load($_FILES['uploaded_image']['tmp_name']); if($image->getWidth() > 150) { //if the image is larger that 150. $image->resizeToWidth(150); //resize to 150. } $target_path = $image_folder.basename($filename); //image path. $image->save($target_path); //save image to a directory. //save array with filenames $images[$count] = $image_folder.$filename; $count = $count+1; }//end if }else{ $error = "Please use jpg, gif, png files"; }//end if }//end if }//end foreach if($error != ''){ echo $error; }else{ /* -------------------------------------------------------------------------------------------------- SAVE TO DATABASE ------------------------------------------------------------------------------------ -------------------------------------------------------------------------------------------------- */ ?> -
I looked at those functions, and they do NOT build the link's right. I would suggest using basic-pagination. Then maybe you could go back and fix the link builds. Hint: Your current link it built like: http://www.nealeweb.com/steven2/index.php&page=3 However, it should be built like: http://www.nealeweb.com/steven2/index.php?page=3 <- it works on your server SEE
-
How do I include a resizing script to my existing script?
jcbones replied to frank_solo's topic in PHP Coding Help
You are not very clear. You want to save the image to a database? You want to save the image path to a database? Does the image upload correctly? Does the script work except for the database entry? -
regex-email listings
-
The variable birthday and telephone are not INSERT INTO
jcbones replied to co.ador's topic in PHP Coding Help
MySQL accepts date's as Y-m-d only. You can submit the date in any format you wish, but you must change it to reflect an acceptable MySQL format. Which is YYYY-mm-dd. Look at: date() strtotime() -
The variable birthday and telephone are not INSERT INTO
jcbones replied to co.ador's topic in PHP Coding Help
What is the value of $birthday? -
Are you inserting them with separate calls to mysql_query(), or are you just delimiting them with a semi-colon, and running one mysql_query() ?
-
After you created your database user, did you go to the next step in cpanel, and add the user to the database?
-
So you should currently have. <html> <head> <title>sss05</title> <style type="text/css"> body{color:blue;background-color:cornsilk} </style> </head> <body> <h1>Comments on my web site.</h1> <?php //script to display comments on my web site & add a new one //check to see if there is a comment to add $error = NULL; if($_GET["comment"]) { $comment = $_GET["comment"]; $email = $_GET["email"]; $time=date('Y-m-d'); //formatted date, as 4 digit Year, 2 digit month, 2 digit day. for insertion into a date column. $conn=mysqli_connect("localhost", "root", "root", "CommentsDB") or die("Unable to connect to database"); $sql="INSERT INTO comments VALUES('$email','$time', '$comment')"; $result=mysqli_query($conn, $sql); if(mysqli_affected_rows($conn)!==1) { $error = "Error - record not inserted"; } } echo "<div>$error</div><table border='1'><tr><td>Email</td><td>Date</td><td>Comment</td></tr>"; $sql="SELECT DATE_FORMAT(`date`, '%e %b, %Y') as `formatted_date`, `email`, `comment` FROM comments"; $result=mysqli_query($conn, $sql) or die("Error selecting -".mysqli_error($conn)); while($row=mysqli_fetch_assoc($result)) { echo "<tr><td>{$row['email']}</td>" ."<td>{$row['formatted_date']}</td>" ."<td>{$row['comment']}</td></tr>"; } ?> </table> </body> </html>
-
You should try something like: <?php include ('includes/db.php'); include ('includes/functions.php'); include ('includes/global.php'); session_start(); echo '<table width="100%">'; $statsql="SELECT wall.by AS wby, wall.date AS wdate, wall.time AS wtime, wall.message AS wmessage, feed.pageid, feed.by, feed.type FROM `feed` JOIN (`wall` LEFT JOIN `users` ON `users`.`id` = `wall`.`by`) ORDER BY wdate "; $statres=mysql_query($statsql) or die(mysql_error()); while($statrow=mysql_fetch_assoc($statres)){ $message=clean_up($statrow['wmessage']); $date=clean_up($statrow['wdate']); $time=clean_up($statrow['wtime']); $by=clean_up($statrow['wby']); $avatar=clean_up($row['avatar']); $first=clean_up($row['first']); if(!isset($storage) || $storage != $message) { echo "<tr class='content'><td valign='top'> <img src='pic.php?w=50&h=50&constrain=1&img=photos/$avatar' /><br>$first</td><td valign='top'> $message</td></tr>"; $storage = $message; } $pageid=clean_up($statrow['pageid']); $type=clean_up($statrow['type']); $by=clean_up($statrow['by']); include("../includes/activity_info.php"); } echo "</table>"; ?> I think you should make sure you Normalize your database. Take the time to go through , that would get you well on your way to understand the importance of making sure your data can be accessed in a Normal form.
-
'".md5($_POST['password])."', //<-missing closing string quote (') after password.
-
You have an empty WHERE clause. Which just needs to be removed. What you do need is some table comparisons as well as identifying the returned result set. SELECT * from `wall`,`feed` WHERE ORDER BY `id` DESC LIMIT 0,10 //should be. SELECT `wall`.*, `feed`.* from `wall` JOIN `feed` ON `wall`.`id` = `feed`.`id` ORDER BY `wall`.`id` DESC LIMIT 0,10 //make sure the comparison in the ON clause is correct.
-
You could set a crontab (*nix server), or event through the task manager (IIS server). This will update based on criteria you set.
-
$array = array('party1','party2','party3','party4','party5'); //array from database. $last = array_pop($array); //remove last value from the array. echo implode(',',$array) . ' and ' . $last; //implode the array on comma's, then append ' and party5' to the end of it.
-
Make Approve Deny and Delete Queries Work
jcbones replied to unemployment's topic in PHP Coding Help
My take: <?php if (isset($_POST['approve'])) { if(is_array($_POST['approve'])) { $keys = array_keys($_POST['approve']); $id = $keys[0]; $sql = " UPDATE `blog_posts` SET `approved` = 1 WHERE `post_id` = '$id' "; } } else if (isset($_POST['deny'])) { if(is_array($_POST['deny'])) { $keys = array_keys($_POST['deny']); $id = $keys[0]; $sql = " UPDATE `blog_posts` SET `approved` = -1 WHERE `post_id` = '$id' "; } } else if (isset($_POST['delete'])) { if(is_array($_POST['delete'])) { $keys = array_keys($_POST['delete']); $id = $keys[0]; $sql = "DELETE FROM `blog_posts` WHERE `post_id` = '$id'"; } } if(isset($sql) && !empty($sql)) { mysql_query($sql) or die(mysql_error()); } foreach ($posts as $post) { ?> <div class="post" id="post<?php echo $post['id']; ?>"> <form action="blog.php" method="post" id="blogform" class="man"> <fieldset class="mvs buttonfield"> <span class="button"> <label> <input type="submit" id="starttop" name="approve[<?php echo $post['id']; ?>]" class="invis dark_grey" value="Approve" /> </label> </span> <span id="smarktop" class="button disabled"> <label> <input type="button" id="marktop" name="deny[<?php echo $post['id']; ?>]" class="invis dark_grey" value="Deny" disabled="disabled" /> </label> </span> <span id="sdeletetop" class="button disabled"> <label> <input type="submit" id="deletetop" name="delete[<?php echo $post['id']; ?>]" class="invis dark_grey" value="Delete" disabled="disabled" /> </label> </span> </fieldset> </form> </div> <?php } ?> -
Make Approve Deny and Delete Queries Work
jcbones replied to unemployment's topic in PHP Coding Help
1. You need to decide if you only want to approve, deny, or delete one record at a time. A. Current way you have it -> submit buttons. B. Multiple at a time -> checkboxes. 2. Either way, you need to define the id of the row you wish to approve, deny, or delete. A. Use a hidden input field. B. Create a array on the submit buttons, using the row identifier as the array key. 3. Your variables are called wrong. A. It should be {$post['id']}, not ${post['id']}. B. You are trying to call the variable, before it is declared. $post isn't declared until the foreach loop, further down the page. -
If the page would load I'd show you. :/ http://stonedknights.net46.net/view.php?id=14 Ummm, ??? Anyway, I told you in another thread that your variables are out of scope in the function displayBody(), I also told you how to fix it. You should really read up on variable scope.
-
Try it this way: <?php $title="Search"; $metakeywords="search, find"; $metadescription="Search for your love!"; include ('header.php'); $getpage=clean_up($_GET['page']); $getpage = abs((int) ($getpage)); echo ' <table width="100%"><tr><td valign="top" class="content"> <form action="index.php?action=search" method="post"> <b>Seeking Gender</b> <select name="gender"> <option value="">Either</option> <option value="Male">Male</option> <option value="Female">Female</option> </select> <hr> <b>Smoke?</b> <select name="smoke"> <option value="">Doesn\'t matter</option> <option value="Yes">Yes</option> <option value="No">No</option> </select> <hr> <b>Drink?</b> <select name="drink"> <option value="">Doesn\'t matter</option> <option value="Yes">Yes</option> <option value="No">No</option> </select> <hr> <b>Body Type </b> <select name="bodytype"> <option value="">Doesn\'t matter</option> <option value="Slim / Slender">Slim / Slender</option> <option value="Athletic">Athletic</option> <option value="Average">Average</option> <option value="Some extra baggage">Some extra baggage</option> <option value="Body builder">Body builder</option> </select> </td><td valign="top" class="content"> <b>First Name</b> <input type="text" name="first" size="17"><br> <b>Last Name</b><input type="text" name="last" size="17"> <hr> <b>Sexual orientation</b> <select class="orientation" name="orientation"> <option value="">Any</option> <option value="Bi">Bi</option> <option value="Gay/Lesbian">Gay/Lesbian</option> <option value="Straight">Straight</option> </select> <hr> <b>Age Range</b> <select class="date" name="age_from">'; $years = range( 16, 100 ); foreach( $years as $v ) { echo "<option value=\"$v\">$v</option>\n"; } echo ' </select> to <select class="date" name="age_to">'; $yyears = range( 17, 100 ); foreach( $yyears as $v ) { echo "<option value=\"$v\">$v</option>\n"; } echo '</select> </td><td valign="top" class="content"> <b>Religion</b> <select name="religious"> <option value="">Any</option> <option value="Agnostic">Agnostic</option> <option value="Atheist">Atheist</option> <option value="Buddhist">Buddhist</option> <option value="Catholic">Catholic</option> <option value="Christian">Christian</option> <option value="Hindu">Hindu</option> <option value="Jewish">Jewish</option> <option value="Mormon">Mormon</option> <option value="Muslim">Muslim</option> <option value="Other">Other</option> <option value="Protestant">Protestant</option> <option value="Satanist">Satanist</option> <option value="Scientologist">Scientologist</option> <option value="Taoist">Taoist</option> <option value="Wiccan">Wiccan</option> </select> <hr> <b>Ethnicity</b> <select name="ethnicity"> <option value="">Any</option> <option value="Asian">Asian</option> <option value="Black / African descent">Black / African descent</option> <option value="East Indian">East Indian</option> <option value="Latino / Hispanic">Latino / Hispanic</option> <option value="Middle Eastern">Middle Eastern</option> <option value="Native American">Native American</option> <option value="Pacific Islander">Pacific Islander</option> <option value="White / Caucasian">White / Caucasian</option> <option value="Other">Other</option> </select> <hr> <b>Children</b> <select name="children"> <option value="">Doesn\'t matter</option> <option value="I don\'t want kids">I don\'t want kids</option> <option value="Love kids, but not for me">Love kids, but not for me</option> <option value="Undecided">Undecided</option> <option value="Someday">Someday</option> <option value="Expecting">Expecting</option> <option value="Proud parent">Proud parent</option> </select> <hr> <b>Education</b> <select name="education"> <option value="">Doesn\'t matter</option> <option value="High school">High school</option> <option value="Some college">Some college</option> <option value="In college">In college</option> <option value="College graduate">College graduate</option> <option value="Grad / professional school">Grad / professional school</option> <option value="Post grad">Post grad</option> </select> <br><input type="submit" name="submit" value="Search" /></form> </td></tr></table>'; if($_POST['submit'] || $_GET['page'] > "0"){ $first = clean_up($_POST['first']); $last = clean_up($_POST['last']); $smoke = clean_up($_POST['smoke']); $drink = clean_up($_POST['drink']); $gender = clean_up($_POST['gender']); $age_from = clean_up($_POST['age_from']); $age_to = clean_up($_POST['age_to']); $orientation = clean_up($_POST['orientation']); $religious = clean_up($_POST['religious']); $ethnicity = clean_up($_POST['ethnicity']); $bodytype = clean_up($_POST['bodytype']); $children = clean_up($_POST['children']); $education = clean_up($_POST['education']); if(!$_GET['page']){ if(!$first == ""){ setcookie("first", $first, time()+3600); } if(!$last == ""){ setcookie("last", $last, time()+3600); } if(!$smoke == ""){ setcookie("smoke", $smoke, time()+3600); } if(!$drink == ""){ setcookie("drink", $drink, time()+3600); } if(!$gender == ""){ setcookie("gender", $gender, time()+3600); } if(!$age_from == ""){ setcookie("age_from", "$age_from", time()+3600); } if(!$age_to == ""){ setcookie("age_to", "$age_to", time()+3600); } if(!$orientation == ""){ setcookie("orientation", $orientation, time()+3600); } if(!$religious == ""){ setcookie("religious", $religious, time()+3600); } if(!$ethnicity == ""){ setcookie("ethnicity", $ethnicity, time()+3600); } if(!$bodytype == ""){ setcookie("bodytype", $bodytype, time()+3600); } if(!$children == ""){ setcookie("children", $children, time()+3600); } if(!$education == ""){ setcookie("education", $education, time()+3600); } } $qquery = "SELECT `id`, `first`, `last`, `avatar`, `gender`, `about`, ( (DATE_FORMAT(CURDATE(),'%Y') - DATE_FORMAT(`bdate`, '%Y') ) - ( DATE_FORMAT(CURDATE(), '00-%m-%d') < DATE_FORMAT( `bdate`, '00-%m-%d')) ) AS age FROM `users` WHERE ( (DATE_FORMAT(CURDATE(),'%Y') - DATE_FORMAT(`bdate`, '%Y') ) - ( DATE_FORMAT(CURDATE(), '00-%m-%d') < DATE_FORMAT( `bdate`, '00-%m-%d')) ) BETWEEN $age_from AND $age_to"; // if any of the options that are stored in the `users` table are selected, add AND to the query string, //and store each needed part in an array, $users_criteria if( $gender != "" || $first != "" || $last != "" ) { $qquery .= ' AND '; $users_criteria = array(); if( !empty($gender) ) { $users_criteria[] = "`gender` = '$gender'"; } if( !empty($first) ) { $users_criteria[] = "`first` LIKE '%$first%'"; } if( !empty($last) ) { $users_criteria[] = "`last` LIKE '%$last%'"; } $qquery .= implode( ' AND ', $users_criteria ); // implode the array, separating each part with AND, and append to query string } // Same process as above, but for results that come from `questions` table if( $smoke != '' || $drink != '' || $orientation != '' || $religious != '' || $ethnicity != '' || $bodytype != '' ) { $qquery .= ' AND id IN( SELECT `userid` FROM `questions` WHERE '; $questions_criteria = array(); if( !empty($smoke) ) { $questions_criteria[] = "`smoke` = '$smoke'"; } if( !empty($drink) ) { $questions_criteria[] = "`drink` = '$drink'"; } if( !empty($orientation) ) { $questions_criteria[] = "`orientation` = '$orientation'"; } if( !empty($religious) ) { $questions_criteria[] = "`religious` = '$religious'"; } if( !empty($ethnicity) ) { $questions_criteria[] = "`ethnicity` = '$ethnicity'"; } if( !empty($bodytype) ) { $questions_criteria[] = "`body_type` = '$bodytype'"; } if( !empty($children) ) { $questions_criteria[] = "`children` = '$children'"; } if( !empty($education) ) { $questions_criteria[] = "`education` = '$education'"; } $qquery .= implode( ' AND ', $questions_criteria ); $qquery .= ' )'; } $total = mysql_num_rows(mysql_query($qquery)); $page_count = ceil($total / 2); $page = 1; if (isset($getpage) && $getpage >= 1 && $getpage <= $page_count) { $page = (int)$getpage; } $skip = ($page - 1) * 2; $query = $qquery . ' LIMIT $skip, 2"'; echo "<table width='100%' align='center'>"; if( $result = mysql_query( $query ) ) { if( mysql_num_rows($result) > 0 ) { while( $rr3 = mysql_fetch_assoc($result) ) { $user=clean_up($rr3[id]); $first=clean_up($rr3[first]); $last=clean_up($rr3[last]); $avatar=clean_up($rr3['avatar']); $about=clean_up($rr3[about]); echo "<tr><td valign='top' width='140' class='content'><center><img src='avatars/thumb/$avatar' /><br><a href='index.php?action=profile&id=$user'> $first $last</a></center></td><td class='content' valign='top'>".limitdesc($about)."</td></tr>"; } } else { echo '<tr><td colspan="2">Sorry, your search returned no results.</td></tr>'; } } else { echo '<tr><td colspan="2">We\'re sorry, there has been an error processing your request. Please try later.</td></tr>'; } echo "</table>"; echo "<div class='content'><center>"; if($getpage == 0 || $getpage == 1){}else{ $plink = $getpage - 1; echo " <a href='index.php?action=search&page=$plink'>Previous</a> "; } echo "<select id='ddp' onchange='document.location=(ddp.value)'> <option value=''>Page #</option>"; for ($i = 1; $i <= $page_count; ++$i){ echo ' <option value="index.php?action=search&page=' . $i . '">' . $i . '</option>'; } echo "</select>"; if($getpage == $page_count){}else{ if($page_count>1){ if($getpage == 0){ echo " <a href='index.php?action=search&page=2'>Next</a> "; }else{ $nlink = $getpage + 1; echo " <a href='index.php?action=search&page=$nlink'>Next</a> "; } } } echo "</center></div>"; } include ('footer.php'); ?> This insures that you are asking for the same thing in the result query, as in the query asking for a row count.
-
So, now your trigger will look something like: DELIMITER ;; CREATE TRIGGER dislikes AFTER INSERT ON Dislikes FOR EACH ROW BEGIN DECLARE disliked INTEGER; DECLARE liked INTEGER; DECLARE date INTEGER; SELECT COUNT(*) INTO disliked FROM dislike WHERE linked_key = 'NEW.linked_key'; SELECT COUNT(*) INTO liked FROM likes WHERE linked_key = 'NEW.linked_key'; SELECT DATEDIFF(NOW(),date_posted) INTO date FROM date_posted WHERE linked_key = 'NEW.linked_key'; UPDATE POSTS SET Popularity = ((20*liked)-(20*disliked))/date WHERE linked_key = 'NEW.linked_key'; END;; DELIMITER; I could help you more, but I would need some table structures. I have no clue what columns link the tables together.