Jump to content

watts

Members
  • Posts

    23
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

watts's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Okay, it's resolved. It was a server side issue.
  2. I just tried this and it still doesn't work.
  3. Upon further investigation I have found that I'm not connecting to the db. I know that I have the right dbname, username and password but the error message says "access denied." Here's the connection code: $db_user="user"; $db_pword="password"; $db_host="localhost"; $db_name="database"; $connection = mysql_connect($db_host, $db_user, $db_pword) or die ("could not connect to server"); $db = mysql_select_db($db_name, $connection) or die ("could not connect to database".mysql_error());
  4. So here's what I get now: "Could not add you to mailing list sql:INSERT INTO 'mailing' ('usrName','usrEmail','usrDatereg') VALUES (bob,bob@mail.com,2009-11-09) error: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 ''mailing' ('usrName','usrEmail','usrDatereg') VALUES (bob,bob@' at line 1". When I look at the manual I still can't figure out the problem. The version of mysql is 4.1.22 My form is GET I changed the back ticks to regular single quotes. I added mysql_real_escape() to sanitize the data. I echoed $sql and all the data looks fine. Here's the code as it stands now. $Fname = mysql_real_escape_string($_GET['Fname']); $eMail = mysql_real_escape_string($_GET['eMail']); $submit = mysql_real_escape_string($_GET['submit']); if ($submit == 1) { $date = date("Y-m-d"); $sql="INSERT INTO 'mailing' ('usrName','usrEmail','usrDatereg') VALUES ($Fname,$eMail,$date)"; $adduser=mysql_query($sql) or die ('Could not add you to mailing list<br/>'.'sql:'.$sql.'<br/>error:'.mysql_error()); $message = "Welcome to the mailing list! $Fname, $eMail, $date."; }
  5. Hi, I can't figure out why it won't add the record to the database. It's just a simple form to get name and email but when I hit submit I get the "or die" message. $Fname = $_GET['Fname']; $eMail = $_GET['eMail']; $submit = $_GET['submit']; if ($submit == 1) { $date = date("Y-m-d"); $sql="INSERT INTO `my_db`.`my_table` ( `usrID` , `usrName` , `usrEmail` , `usrDatereg` ) VALUES ( NULL , '$Fname', '$eMail', '$date' )"; $adduser=mysql_query($sql) or die ('Could not add you to mailing list'); $message = "Welcome to the mailing list! "; } It's definitely getting all the variables from the form, I tested by printing them as part of the $message variable but it just isn't adding. Any thoughts? Thanks.
  6. This may be a stupid question but is there a way for me to check if a string contains numbers?  I'm trying to do a form validation where I can make sure that certain fields only contain letters or numbers. Thanks
  7. I know this isn't the problem because the $toAddress variable is also enclosed in "" and that works fine.  I can't figure it out for the life of me.
  8. I've recently uploaded my site from my local server to a remote server.  I've been using phpMailer to send an email with multiple attachments using the AddAttachment function.  It works fine on my local server but now on the remote server it sends the email but there are no attachments.  [code] $mail->AddAttachment("$imgThbURL"); //$imgThbURL is the path to the image file pulled from the db [/code] I've checked and it's retrieving the image path fine but it's just not attaching the file. Does anyone have any ideas on what might be wrong here?
  9. My recommendation is to check out the "mysql full-text searching with php" tutorial.  I used this but removed the choice between "normal" and "boolean mode" so it was only boolean.  The default is to use normal mode where it searches for "any words" as opposed to "all words."  If you use a boolean mode query you can then force it to look for all words by using a little str_replace to add boolean operators to the search string and specifying boolean mode in your query.  I did this and it worked like a charm (on my local server).  Unfortunately it seems to only search for the first word on my remote server but that's another problem that has yet to be explained.  This is what I did: [code] //ADD BOOLEAN OPERATORS //CHECK IF IT'S FIRST SEARCH PAGE OR IF BOOLEAN OPERATORS HAVE ALREADY BEEN ADDED if (isset($_GET['words'])) {   $words=$_GET['words']; // the $words variable was defined in the search form (see tutorial)   $newWords = str_replace(' ','+',$words);   $newWords = str_replace($newWords,'+'.$newWords,$newWords); } elseif (isset($_GET['newWords'])) {   $newWords = $_GET['newWords']; } $searchstring = mysql_escape_string($newWords);     $sqlCount = "SELECT imgID, imgURL, imgThbURL, imgLabel, imgCaption, imgTitle, imgTitleMeta, imgDescription,                 MATCH(imgTitle, imgCaption, imgDescription)                 AGAINST ('$searchstring' IN BOOLEAN MODE) AS score FROM images                 WHERE MATCH(imgTitle, imgCaption, imgDescription)                 AGAINST ('$searchstring' IN BOOLEAN MODE) ORDER BY score DESC";     $result = mysql_query($sqlCount) or die (mysql_error('There were no items to match your search, please use exact words.'));     $searchRows = mysql_num_rows($result); [/code] hope that helps!
  10. If you google "database design tutorial" or "relational database design tutorial" you should be able to find something.  Or get a book from the bookstore or the library that walks you through the logical process of db design.  You have to know exactly what the data you want to store is, how you would break it down into distinct fields (i.e., first name, last name, product number, product name, product description) , how these different fields relate to eachother (do you need one-to-one relationships or one-to-many?)  How will you structure your data to avoid repetition?  It's very important that you put enough thought into this, you don't want to be halfway through you're coding and realize there's a fundamental flaw in the structure of your db.  I recommend getting a book and really thinking about what your data is and what you want to do with it. Kristin
  11. I figured it out, I should have had the width and height in the style for the <li> not the <a>. Thanks, Kristin
  12. I'm trying to create a group of navigation buttons using <ul> and background images.  The problem is that no matter what I set the height and width of the <li> or <ul> or <a> the image only shows directly behind the words and I don't get the full button.  html: [code]   <div id="siteNav">     <ul id="siteNavList">       <li id="stock"><a href="http://www.skyartstock.com" title="stock photos">stock photos</a></li>       <li id="prints"><a href="http://www.skyartprints.com" title="fine art prints">fine art prints</a></li>       <li id="aj"><a href="http://www.arjenandjerrineverkaik.com" title="a & j verkaik">a & j verkaik</a></li>     </ul>   </div> [/code] css: [code] #siteNav { margin: 100px 0px 0px 800px; width: 97px; } #siteNavList {         white-space:nowrap; list-style-type:none; width: 97px; } #siteNav ul li { font-size: 10pt; } #siteNav ul li a { width: 97px; height: 27px; color: #FFF; text-decoration: none; } #siteNav ul li a:visited { color: #C36AC9; text-decoration: none; width: 97px; height: 27px; } #stock a { background-image: url(../images/SS-002311.jpg); background-repeat: no-repeat; width: 97px; height: 27px; } #prints a{ background-image: url(../images/SP-915525.jpg); background-repeat: no-repeat; width: 97px; height: 27px; } #aj a { background-image: url(../images/AJ-002335.jpg); background-repeat: no-repeat; width: 97px; height: 27px; } [/code] If anyone has any ideas I'd love to hear them. Thanks!
  13. I've just uploaded my site from my local server, where everything worked fine, to a new remote server and my full-text search is no longer working properly.  It's not using boolean mode and it's only returning results for the first word in the search string so if the search string is "abstract vertical" it returns the same number of results as "abstract" Here's code for the search: [code] function searchForm() { //reusable form //variable setup for the form $searchwords = (isset($GET['newWords']) ? htmlspecialchars(stripslashes($_REQUEST['words'])) :''); echo "<div id='searchField'>\n"; echo "<form method='get' action='".$_SERVER['PHP_SELF']."'>\n"; echo "<input type='hidden' name='cmd' value='search' />\n"; echo "Search for: <input type='text' name='words' value='".$searchwords."' />&nbsp;\n"; echo "<input type='submit' value='SEARCH' />\n"; echo "</form>\n"; echo "<p>Enter your keywords separated by spaces.  The search will only return exact matches (no partial word matches) for all words present and display the thumbnails.</p>\n"; echo "</div>\n"; //END DIV FOR SEARCHFIELD } //ADD BOOLEAN OPERATORS //CHECK IF IT'S FIRST SEARCH PAGE OR IF BOOLEAN OPERATORS HAVE ALREADY BEEN ADDED if (isset($_GET['words'])) {   $words=$_GET['words'];   $newWords = str_replace(' ','+',$words);   $newWords = str_replace($newWords,'+'.$newWords,$newWords); } elseif (isset($_GET['newWords'])) {   $newWords = $_GET['newWords']; } // CREATE THE NAVIGATION SWITCH $cmd = (isset($_GET['cmd']) ? $_GET['cmd'] : ''); switch($cmd) {   default;     echo "<h2>Search Images</h2>";     searchForm();   break;   case "search";     searchForm(); //OPEN DIV FOR DISPLAYED RESULTS     echo "<div id=searchResults>\n";     $searchstring = mysql_escape_string($newWords); //SET LIMIT AND DETERMINE NUMBER OF IMAGES $limit = 20; $perRow = 4;     $limitValue=($page*$limit)-($limit);     $table_row=1;         $sql = "SELECT imgID, imgURL, imgThbURL, imgLabel, imgCaption, imgTitle, imgTitleMeta, imgDescription,                 MATCH(imgTitle, imgCaption, imgDescription)                 AGAINST ('$searchstring' IN BOOLEAN MODE) AS score FROM images                 WHERE MATCH(imgTitle, imgCaption, imgDescription)                 AGAINST ('$searchstring' IN BOOLEAN MODE) ORDER BY score DESC LIMIT $limitValue, $limit";     $result = mysql_query($sql) or die (mysql_error('Could not connect to database'));     $countImg = mysql_num_rows($result); [/code] This works fine on my local server which is running mysql 5 but it doesn't work properly on the remote server which is running mysql 4.1.10.
  14. This seems like a stupid question but I'm trying to use a piece of freeware to convert and upload a db from access to mysql.  The conversion is working fine but when I try to upload it it's not connecting to the server.  So here's my question.  I know that when I'm connecting to a db from a script on the server the host is "localhost"  but when I'm trying to connect from outside the server what is the host?  Is it the ip address or the domain or something else?  I know the db name, username and password are correct so I think there's something wrong with the hostname I'm using. Any suggestions would be appreciated. Thanks.
×
×
  • 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.