Jump to content

znaji

Members
  • Posts

    10
  • Joined

  • Last visited

znaji's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi Would like to rewrite this patch of MySQL update query better can someone please help. $sqlStatment = "UPDATE products SET " . "catid=" . $_REQUEST['cat'] . ", cattxt='" . $catText . "', ptitle='" . $_REQUEST['ptitle'] . "', saleoffer='" . $_REQUEST['saleoffer'] . "', url='" . $_REQUEST['url'] . "', tag=" . $_REQUEST['tag'] . "', oldprice=" . $_REQUEST['oprice'] . ", nprice=" . $_REQUEST['nprice'] . ", availability=" . $_REQUEST['availability'] . ", shortdesc = :shortdescription" . ", pdescription = :description" . ", meta_title =" . $_REQUEST['meta_title'] . ", meta_keyword =" . $_REQUEST['meta_keyword'] . "', meta_description=" . $_REQUEST['meta_description'] . ", last_modified = NOW()" . " WHERE id=" . $_REQUEST['pid']; try{ $query = $db->prepare($sqlStatment); $query->execute(array(':shortdescription'=>$_REQUEST['shortdescription'], ':description'=>$_REQUEST['description'])); } catch(PDOException $e) { die($e->getMessage()); } Thank you for any help.
  2. Thank you for the soultion and lesson.
  3. Sorry to add to this thread however getting another issue same as before. Any help would be appreicated. Warning/Error Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/content/91/12175191/html/file.php on line 72 Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/content/91/12175191/html/file.php on line 144 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 'BY status_id DESC LIMIT 10' at line <?php $grumble = true; $exist = false; if(isset($_GET["subcat"]) && is_numeric($_GET["subcat"])) { $subcat = mysql_real_escape_string($_GET["subcat"]); $sql = "SELECT status_id FROM status_grumble " . "WHERE sub_category_id = " . $subcat . "ORDER BY status_id DESC LIMIT 10"; $result = mysql_query($sql, $conn); /* SQL syntax Error Check */ if (false === $result) { echo mysql_error(); } /* SQL syntax Error Check */ $sql = "SELECT scg.sub_category_id, scg.sub_category_name, scg.sub_category_created, scg.grumble_number, " . "scg.sub_category_description, scg.sub_category_url, cg.category_name, cg.category_id, cg.category_url, " . "ug.username, COUNT(ulg.user_like_id) AS votes_up FROM sub_category_grumble AS scg " . "LEFT OUTER JOIN categories_grumble AS cg ON scg.category_id = cg.category_id " . "LEFT OUTER JOIN users_grumble AS ug ON scg.user_id = ug.user_id " . "LEFT OUTER JOIN user_likes_grumble AS ulg ON ulg.sub_category_id = scg.sub_category_id " . "WHERE scg.sub_category_id = " . $subcat . " LIMIT 0,1"; $result2 = mysql_query($sql, $conn); if(mysql_num_rows($result2) != 0) $exist = true; } if($exist) { $row = mysql_fetch_array($result2); ?> Line 72 if(mysql_num_rows($result) == 0) { echo '<div id="comments-left">'; if(isset($_SESSION["username"])) { Line 144 if(mysql_num_rows($result) < 10) Thanks again for any help. I am still going to try to figure it out on my own if i dont get help figuring this out first
  4. Thank you I was over thinking it. However I found a simple soultion for Godaddy hosting (In my case). Just add the follwoing and it fixed it right away. #Fix Rewrite Options -Multiviews
  5. Hi Rewrite rules will not work on cheap hosted godaddy server however rewrite works locally. Can someone le me know whats wrong or the right way please. Working locally but not hosted. RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] #AddType application/x-httpd-php .php5 .php4 .php .php3 .php2 .phtml #AddHandler x-httpd-php5-3 .php RewriteRule ^profile/([a-zA-Z0-9_-]+)/comment/([0-9]+) statusview.php?s=$2&user=$1 RewriteRule ^profile/([a-zA-Z0-9_-]+)/notifications notifications.php?userid=$1 RewriteRule ^profile/([a-zA-Z0-9_-]+) profile.php?id=$1 RewriteRule ^create-account create-account.php RewriteRule ^forgot-password forgot-password.php RewriteRule ^about about.php RewriteRule ^privacy privacy.php RewriteRule ^terms-of-service terms-of-service.php RewriteRule ^contact contact.php RewriteRule ^login login.php RewriteRule ^([a-z_-]+)/([a-z0-9_-]+)/([0-9]+) comment.php?subcat=$3 RewriteRule ^category/([a-zA-Z_-]+) category.php?cat=$1 RewriteRule ^how-it-works how-it-works.php RewriteRule ^updates updates.php Link http://www.example.com/profile/john does not work have to use http://www.example.com/profile.php?id=john to test.
  6. D'ah (On my part).... Your are the best Thank you so much! It worked. Changed: From: "WHERE scg.sub_category_id = " . $grumble . "LIMIT 0, 1"; To: "WHERE scg.sub_category_id = " . $grumble . " LIMIT 0,1";
  7. Thank you for the feedback and info. However still new to php and MySQL. How would i go about doing this.
  8. Hi Hoping for some help after resolving other errors/warnings and spending abit on one issue and havent figured it out. I was hoping for some help here. Thanks for any help. Error: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/content/91/12175191/html/php/file.php on line 16 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 '0, 1' at line 1 <?php function outputGrumbles($grumble, $home = false) { global $conn; if($grumble) { setTimezone(); $sql = "SELECT cg.category_name, cg.category_url, scg.sub_category_id, scg.sub_category_name, scg.sub_category_description, scg.sub_category_url, " . "(COUNT(DISTINCT sg.status_id) + COUNT(DISTINCT ulg.user_like_id)) AS grumble_number, " . "DATE_FORMAT(scg.sub_category_created, '%b %e, %Y %l:%i %p') AS sub_category_created " . " FROM sub_category_grumble AS scg " . "LEFT OUTER JOIN categories_grumble AS cg ON cg.category_id = scg.category_id " . "LEFT OUTER JOIN status_grumble AS sg ON sg.sub_category_id = scg.sub_category_id " . "LEFT OUTER JOIN user_likes_grumble AS ulg ON ulg.sub_category_id = scg.sub_category_id " . "WHERE scg.sub_category_id = " . $grumble . "LIMIT 0, 1"; $result = mysql_query($sql, $conn); if($row = mysql_fetch_array($result)) { echo '<div class="grumble-holder">'; echo '<div class="'; if($home) { echo 'content-padding-home'; } else { echo 'content-padding'; } echo '">'; echo '<div class="grumble-comment-number">'; if($home) echo '<p><a href="/category/' . $row["category_url"] . '" class="colored-link-1 grumble-cat-name" title="' . $row["category_name"] . '">' . $row["category_name"] . '</a></p>'; echo '<p class="grumble-comment-font" title="' . $row["grumble_number"] . ' comments/votes on this Grumble">'; echo $row["grumble_number"]; echo '</p>'; echo '</div>'; echo '<div class="grumble-text-holder">'; echo '<h3><a href="/' . ($row["category_url"]) . '/' . $row["sub_category_url"] . '/' . $row["sub_category_id"] . '" data-id="' . $row["sub_category_id"] . '" class="colored-link-1">' . stripslashes($row["sub_category_name"]) . '</a></h3>'; echo '<p class="grumble-description">' . stripslashes($row["sub_category_description"]) . '</p>'; echo '</div>'; echo '</div>'; echo '</div>'; } if (false === $result) { echo mysql_error(); } } } ?> Again thank you for any help.
  9. Hi I just started to learn how to code and love learning new things. I started with reading codes and just playing around and now I'm trying to fix finish this code. My goal is for this to handle errors (username, email) prevent duplicate entries in MySql and return error (invaild email, username already exist etc) via ajax. I learn faster and better by example if anyone can help and show me a revised code i would greatly appricate it. <?php if(isset($_POST['username']) && !empty($_POST['username']) AND isset($_POST['email']) && !empty($_POST['email'])){ $username = mysql_escape_string($_POST['username']); $email = mysql_escape_string($_POST['email']); if(!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $email)){ // Return Error - Invalid Email $msg = 'The email you have entered is invalid, please try again.'; }else{ // Return Success - Valid Email $msg = 'Your account has been made, <br /> please verify it by clicking the activation link that has been send to your email.'; $hash = md5( rand(0,1000) ); // Generate random 32 character hash and assign it to a local variable. $password = substr(hash('sha512',rand()),0,50); mysql_query("INSERT IGNORE INTO users (username, password, email, hash, ip, whenadded) VALUES( '". mysql_escape_string($username) ."', '". mysql_escape_string(md5($password)) ."', '". mysql_escape_string($email) ."', '". mysql_escape_string($hash) ."', '". $_SERVER['REMOTE_ADDR'] ."', now()) ") or die(mysql_error()); $to = $email; //Send email to user $subject = 'Signup | Verification'; //// Give the email a subject $message = ' Thanks for signing up! Your account has been created, you can login with the following credentials after you have activated your account by pressing the url below. ------------------------ Username: '.$username.' Password: '.$password.' ------------------------ Please click this link to activate your account: http://www.example.com/verify.php?email='.$email.'&hash='.$hash.' '; // Our message above including the link $headers = 'From:noreply@yourwebsite.com' . "\r\n"; // Set from headers mail($to, $subject, $message, $headers); // Send the email } } ?> <?php if(isset($msg)){ // Check if $msg is not empty echo '<div class="statusmsg">'.$msg.'</div>'; } ?> <form id="form" class="form" action="" method="post"> <ul> <li> <label for="username">Name</label> <input class="text" type="text" placeholder="Username" size="50" id="username" name="username" tabindex="1" /> </li> <li> <label for="email">Email</label> <input class="text" type="text" placeholder="Email address" size="50" id="email" name="email" tabindex="2" /> </li> </ul> <input type="submit" class="submit_button" value="Sign up" /> </form>
×
×
  • 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.