Jump to content

m2e

Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

m2e's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have recently moved my site over to the new just hosting site - and as such the search functionality has stopped working - I have changed all the db connection - however I am getting some errors. as below The page can be found here: (http://www.jpaero-com.co.uk/rfq.php) , I get the following error (searching for 00001) Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/jpaeroc1/public_html/search.php on line 255 Results Below is my PHP <?php // Get the search variable from URL $var = @$_GET['q'] ; $trimmed = trim($var); //trim whitespace from the stored variable // rows to return $limit=10; // check for an empty string and display a message. if ($trimmed == "") { echo "<p>Please enter a search by clicking here</p>"; exit; } // check for a search parameter if (!isset($var)) { echo "<p>We dont seem to have a search parameter!</p>"; exit; } //connect to your database ** EDIT REQUIRED HERE ** mysql_connect("localhost", "jpaeroc1_jpadmin", "cherrytree"); //(host, username, password) //specify database ** EDIT REQUIRED HERE ** mysql_select_db("jpaeroc1_stock") or die("Unable to select database"); //select which database we're using // Build SQL Query $query = "select Part_Number, Part_Condition_Code, Description, Stock_Level, Unit_of_Measure from jpaero_stocksearch where Part_Number like \"%$trimmed%\" order by Part_Number"; // EDIT HERE and specify your table and field names for the SQL query $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); // If we have no results, offer a google search as an alternative if ($numrows == 0) { echo "<h4>Results</h4>"; echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>"; // google echo "<p><a href=\"http://www.jpaero-com.co.uk/rfq.php\"></a></p>"; exit; } // next determine if s has been passed to script, if not use 0 if (empty($_GET['s'])) { $s=0; } else { $s = intval($_GET['s']); } // get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); // display what the person searched for echo "<p>You searched for: "" . $var . ""</p>"; // begin to show results set echo "Results"; $count = 1 + $s ; // now you can display the results returned while ($row= mysql_fetch_array($result)) { ?> </p> <br /> </p> <table width="546" border="0" cellpadding="0" bordercolor="#000000" bgcolor="#FFFFFF"> <tr> <td width="86" bgcolor="#000066"><span class="style16 style14 style12"><strong>Part Number</strong></span></td> <td width="83" bgcolor="#000066"><span class="style16 style14 style12"><strong>Part<br /> Condition <br /> Code</strong></span></td> <td width="152" bgcolor="#000066"><span class="style16 style14 style12"><strong>Description</strong></span></td> <td width="75" bgcolor="#000066"><span class="style16 style14 style12"><strong>Stock Level</strong></span></td> <td width="98" bgcolor="#000066"><span class="style16 style14 style12"><strong>Unit of Measure</strong></span></td> </tr> <tr> <td><span class="style12 style13"><? echo $row["Part_Number"]; ?></span></td> <td><span class="style13"><? echo $row["Part_Condition_Code"]; ?></span></td> <td><span class="style13"><? echo $row["Description"]; ?></a></span></td> <td><span class="style13"><? echo $row ["Stock_Level"]; ?></span></td> <br /> <td><span class="style13"><? echo $row ["Unit_of_Measure"]; ?></span></td> </tr> </table> <? } $currPage = (($s/$limit) + 1); //break before paging echo "<br />"; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 10</a>&nbsp "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; echo " <a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 >></a>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p>Showing results $b to $a of $numrows</p>"; ?>
  2. Hello there, I have a script which uses the LOAD DATA LOCAL INFILE command see below: <?php //connect to your database mysql_connect("localhost", "xxx", "xxx"); //(host, username, password) //specify database mysql_select_db("xxx") or die("Unable to select database"); //select which database we're using // Build SQL Query $query = "LOAD DATA INFILE '/public_html/admin/files/test-jp-stock.csv' INTO TABLE 'jpaero_stocksearch' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 1 LINES"; if(mysql_query($query)){ echo ">> New Stock Data has now been uploaded. Database is now live and searchable.";} else{ echo "Upload failed. Please contact support.";} ?> Initially I uploaded the csv file through phpmyadmin and everything worked fine - so I then used the SQL generated inside my script, changing the location to where the file actually is - however now nothing happens at all. Any ideas on whats gone wrong, gratefully received! Thanks,
  3. Really hoping someone can help me, cos I can't seem to figure this out! Ok - so I am running a search on a database, showing the results over x pages (10 results to a page) However, my link to go onto the next search page does not work. It just reloads the same page i.e. does nothing. I think I'm not correctly passing the s variable, but I also think I have confused myself!! Hoping I can be set straight on this! <?php // Get the search variable from URL $var = @$_GET['q'] ; $trimmed = trim($var); //trim whitespace from the stored variable // rows to return $limit=10; // check for an empty string and display a message. if ($trimmed == "") { echo "<p>Please enter a search by clicking here</p>"; exit; } // check for a search parameter if (!isset($var)) { echo "<p>We dont seem to have a search parameter!</p>"; exit; } //connect to your database ** EDIT REQUIRED HERE ** mysql_connect("192.168.140.18", "u10149947", "jpaero1"); //(host, username, password) //specify database ** EDIT REQUIRED HERE ** mysql_select_db("u10149947") or die("Unable to select database"); //select which database we're using // Build SQL Query $query = "select Part_Number, Part_Condition_Code, Description, Stock_Level, Unit_of_Measure from jpaero_stocksearch where Part_Number like \"%$trimmed%\" order by Part_Number"; // EDIT HERE and specify your table and field names for the SQL query $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); // If we have no results, offer a google search as an alternative if ($numrows == 0) { echo "<h4>Results</h4>"; echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>"; // google echo "<p><a href=\"http://www.jpaero-com.demonweb.co.uk/rfq.php/search?q=" . $trimmed . "\" target=\"_blank\" title=\"Look up " . $trimmed . " on Google\">Click here</a> to try another search</p>"; } // next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } // get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); // display what the person searched for echo "<p>You searched for: "" . $var . ""</p>"; // begin to show results set echo "Results"; $count = 1 + $s ; // now you can display the results returned while ($row= mysql_fetch_array($result)) { ?> </p> <table width="546" border="0" cellpadding="0" bordercolor="#000000" bgcolor="#FFFFFF"> <tr> <td width="86" bgcolor="#000066"><span class="style16 style14 style12"><strong>Part Number</strong></span></td> <td width="83" bgcolor="#000066"><span class="style16 style14 style12"><strong>Part<br /> Condition <br /> Code</strong></span></td> <td width="152" bgcolor="#000066"><span class="style16 style14 style12"><strong>Description</strong></span></td> <td width="75" bgcolor="#000066"><span class="style16 style14 style12"><strong>Stock Level</strong></span></td> <td width="98" bgcolor="#000066"><span class="style16 style14 style12"><strong>Unit of Measure</strong></span></td> </tr> <tr> <td><span class="style12 style13"><? echo $row["Part_Number"]; ?></span></td> <td><span class="style13"><? echo $row["Part_Condition_Code"]; ?></span></td> <td><span class="style13"><? echo $row["Description"]; ?></a></span></td> <td><span class="style13"><? echo $row ["Stock_Level"]; ?></span></td> <br /> <td><span class="style13"><? echo $row ["Unit_of_Measure"]; ?></span></td> </tr> </table> <? } $currPage = (($s/$limit) + 1); //break before paging echo "<br />"; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 10</a>&nbsp "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; echo " <a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 >></a>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p>Showing results $b to $a of $numrows</p>"; ?>
  4. Hello, hope someone can help me out - I have a feeling its somthing silly, but I've been staring at it so long I dont know now! I have a guest list signup form which I have been using for a while. I have moved the code over from another website where it was working - however now it doesnt seem to be working. There are three files:- index.html This contains the form - which uses the post method and sends details to bookings.php bookings.php Does the work of adding the signup to the database and sending an email for the user to confirm their sign-up once they receive this email and click on the link this envokes booking-confirmed.php booking-confirmed.php Sends the user back to the orginal website and prints a message saying that their registration has been successful. The form submits, and an email is sent - but nothing is being written to the database - and the email variable does not seem to be passed to the next page. The form can be seen here http://www.bigsixmedia.net/eventsignup If you click on the link and then fill in the details on the form, and hit submit, the details are sent to the database, with a confirmed marker of 'N' for no. The user is also sent an email (to the address you specified) with a link inside it asking you to click it - this then takes you back to the website and to a confirmation page, the marker in the database is now set to 'Y' for yes. I have also pasted below the php part of booking.php: <?php #ensure all fields have entries if ($fullname and $email and $mobile) { #connect to mysql $conn=@mysql_connect("localhost", "gbsnadmin", "goldcoast1") or die ("Err:Conn"); #select the specified database $rs = @mysql_select_db("gbsn", $conn) or die ("Err:Conn"); #create the 1st query $date="AYEKOO_AP_070309"; $sql="SELECT * FROM event_signups WHERE email = \"".$email."\" AND date = \"".$date."\""; #execute 1st query $rs=mysql_query($sql,$conn); #add entry if NO matching record was found, else deny sign-up if (mysql_num_rows($rs)) { echo "The email address, $email has already been signed up for this event!"; exit; } else { #create the 2nd query $sql="INSERT INTO event_signups(date, fullname, email, mobile) VALUES ( \"$date\", \"$fullname\", \"$email\", \"$mobile\")"; #execute the query $rs=mysql_query($sql,$conn); } #confirm the added record details if($rs) {echo ("Thank you $fullname - We have received your request for guestlist.\n\nTo confirm this an email will be sent to $email - \n\nYOU MUST CLICK ON THE CONFIRMATION LINK - \n\nFailure to do this will result in your name not being submitted"); } } #***************************************************************** #*********************** Send Email Script *********************** #***************************************************************** #this is the recipients email address $to = "rgevans@gmail.com, $email"; #this is the subject of the message $re = "PLEASE CONFIRM YOUR EVENT SIGN-UP"; #build the URL - this is the message with the link to the url $msg = "PLEASE CLICK THE LINK BELOW TO CONFIRM YOUR SIGN-UP\n\nYOU WILL BE SENT A CONFIRMATION EMAIL SHORTLY AFTER THIS\n\nhttp://www.thegbsn.com/eventsignup/booking-confirmed.php?email=$email\n\nIf you can not click on this link copy and paste ALL of the link into your browser"; #this is where the from header is set $headers .= "From: signup@thegbsn.com \r\n"; #this part sends the email mail($to,$re,$msg, $headers); ?> Thanks for your help!!!
  5. Thank you - I got the script from a website - so there was no mail.php attached - I guess I need to find the path for this from my hosting provider and hopefully that should solve it. Will do that and let you know how I get on. Thanks,
  6. Hello, I've recently had to upgrade my sendmail script on my website, due to tighter security. So I now have to use one which uses my SMTP information. My ISP directed me to a script - but as I have very limited knowledge of PHP - I am having some difficulties with it. The first line of the script is require_once "mail.php"; What is mail.php - is this another file somewhere within the PHP installation - or should the file that this code is in be called mail.php? Secondly - what does this require_once actually do? Is it necessary? When I run the script as it is, with this line - I get this error: Warning: main(mail.php) [function.main]: failed to open stream: No such file or directory in /home/rgevans/public_html/event_signup/emailtest.php on line 246 Fatal error: main() [function.require]: Failed opening required 'mail.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/rgevans/public_html/event_signup/emailtest.php on line 246 When I run the script with require_once edited out I get the following error: Fatal error: Undefined class name 'mail' in /home/rgevans/public_html/event_signup/emailtest.php on line 260 The first error would suggest to me that this is a file already installed - the second suggests that this is something created within the code - but again as I said - I'm a novice! My actual code is below: <?php #require_once "mail.php"; $from = "Ment2Excel Guest List <guestlist@ment2excel.com>"; $to = $email; $subject = "Ment2Excel Guest List Registration"; $body = "Hi,\n\nHow are you?"; $host = "mail.XXX.com"; $username = "test@XXX.com"; $password = "XXXXX"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } ?> Thanks in advance for your time.
  7. Thanks - theres a lot there that I can do - I think the most poignant thing for me, was not allowing the posts to appear automatically. I did actually clear them out - but no sooner had I cleared it....... Thanks for all your help.. Regards, Russell
  8. Hi there, I have a very simple guestbook on my website : [a href=\"http://www.ment2excel.com/guestbook/guestbook-view.php\" target=\"_blank\"]http://www.ment2excel.com/guestbook/guestbook-view.php[/a] Today it seems it has been attacked by some random messages. This is not the first time this has happend, but it has never been to this extent. Is there anything that can be done to stop this? Is it a problem with my code, allowing this to happen? Thanks, Russell
  9. Hi there, I've recently purchased a laptop for the purpose of doing PHP development on it - I would like to install PHP on there but wanted to get advice on the best way to do this...I'm looking for an installation which will install all the necessary components (php, mysql, apache) with the least amount of configuraiton and fuss. Thanks in advance!!
×
×
  • 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.