Jump to content

Rhysyngsun

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

About Rhysyngsun

  • Birthday 07/08/1985

Contact Methods

  • AIM
    Rhysyngsun
  • Website URL
    http://www.nathanlevesque.com

Profile Information

  • Gender
    Male
  • Location
    Springfield, MA

Rhysyngsun's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Try taking a look at Chris Schiflett'sb log post on this: http://shiflett.org/blog/2005/oct/convert-smart-quotes-with-php There's a lot of similar solutions out there, maybe this one will work better.
  2. latin1 is mysql's default character encoding. latin1 is equivalent to ISO 8859-1. Which character set are you trying to convert to specifically?
  3. This isn't a MySQL issue, it's a general PHP issue. Basically, the character encoding is set in the header sent by the server. You could try adding the following at the beginning of your file: or whatever charset you need You can also set this in the php.ini file for your entire server I believe
  4. The problem with TIMESTAMP is that if you don't supply a value or pass null to it when updating/inserting it will use the current server time. Use datetime unless you want this automatic functionality.
  5. Say we assign each category, location, etc. choice an id for simplicity and extensibility ("Any" option will always be 0): $hasWhere = false; $q = "SELECT * FROM `table`"; if( $category != "0" ) { if( !hasWhere ) $q .= " WHERE "; $q .= " 'categoryid' = `$category`"; $hasWhere = true; } And so on... You will have to make sure you keep track of whether or not you have WHERE in your query yet, as you should have it only once and only then if you have statements to go with it.
  6. I would generate your SQL statements by concatenating a conditional statement on only if the parameter was not equal to "Any". That way if they do chose "Any", you simply don't append that condition into your SQL statement. If they choose a specific option, then you simply append the relevant condition since that's the only one you're checking for.
  7. Two things to change: 'listings' to either listings or `listings` and then change your &&'s to AND full code: SELECT * FROM listings WHERE 'siteaddy' LIKE '%siteaddy%' OR 'ccontact' LIKE '%name%' OR 'ccompany' LIKE '%cname%' OR 'tenant' LIKE '%tenant%' OR 'sitestate' LIKE '%st%' OR 'propertytype' LIKE '%type%' OR 'askingprice' BETWEEN '0' AND '10' OR 'caprate' BETWEEN '0' AND '10' OR 'cashoncash' BETWEEN '0' AND '10' ORDER BY id DESC LIMIT 0 , 30
  8. It apparently fixed itself. Not sure why. Here's my final code (the original code also runs fine ): # Construct query string $q = "SELECT * FROM `".TBL_CONTENT."` WHERE `id` = '$id'"; # Send query $result = $this->database->query( $q ); # Get our row if( $result ) { if( $row = mysql_fetch_assoc( $result ) ) { # Store data $this->id = $row["id"]; $this->title = $row["title"]; $this->data = $row["data"]; $this->parentid = $row["parentid"]; } }
  9. I still get the error. I even tried hard coding the SQL command with the one that works is supposedly generated and works only in phpMyAdmin so that there's no issues about string concatenation or variables. I was really hoping this was some silly mistake brought on by tunnel vision. ???
  10. Contained in a class that handles my content: public function getContentByID( $id ) { # Construct query string $q = "SELECT * FROM `".TBL_CONTENT."` WHERE `id` = '$id'"; # Send query $result = $this->database->query( $q ); # Get our row if( $row = mysql_fetch_row( $result ) ) { # Store data $this->id = $row["id"]; $this->title = $row["title"]; $this->content = $row["data"]; $this->parentid = $row["parentid"]; } else mysql_error(); } $this->database is an object that keeps track of the connection and provides a query function as follows: public function Query( $query ) { return mysql_query( $query, $this->conn ) or die( mysql_error() ); }
  11. The presence or lack of semicolon in my sql statement made no difference. I actually added it at one point in the hopes it would resolve my issue.
  12. I get the following Error: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in content.php on line 69 I also get this error when performing other MySQL function on this particular result. The code that create my sql query is as follows: $q = "SELECT * FROM `".TBL_CONTENT."` WHERE `id` = '8';"; This generates the following sql (with 8 assigned to $this->id and "content_tbl" assigned to TBL_CONTENT): SELECT * FROM `content_tbl` WHERE `id` = '8'; I know this query works, as I do have a row with id set to 8 and I ran the query in phpMyAdmin and got the correct results. It is also not a connection issue as I am able to promptly delete that very row after the SELECT query. I've also Googled my keyboard into the ground trying to figure this out so any help would be much appreciated.
×
×
  • 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.