Jump to content

Pedestrian

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Pedestrian's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm very new to php/mysql so I apologize if this question is not top-notch: I'm working on a computer conferencing environment, and so far, I can let users post notes. But I want them to be able to tag notes. Do you have any resources I could look into? I want to read up on how I could do something like that - tag notes that is. I'm sorry for asking such a primitive question! But I thought this forum might help me get started. ~P
  2. Thanks for the link. I tried that, but now Apache crashes when I run the code. I get the following error: "Apache HTTP Server Apache HTTP Server has encountered a problem and needs to close. "
  3. Wow ... then I am really worse off then I thought. When I do that, I get this message: Fatal error: Call to undefined function mysql_connect() in C:\Apache2\htdocs\results.php So PHP does not at all recognize MYSQL functions?
  4. I forgot to add that when I take the error suppressor off, I get this: Fatal error: Class 'mysqli' not found in C:\Apache2\htdocs\results.php on line 32 and I have no idea what I'm supposed to do about it! ???
  5. Sorry! I've pasted the code here again! <html> <head> <title>Book-O-Rama Search Results</title> </head> <body> <h1>Book-O-Rama Search Results</h1> <?php // create short variable names echo 'I am here1.'; $searchtype=$_POST['searchtype']; $searchterm=trim ($_POST['searchterm']); if (!$searchtype || !$searchterm) { echo 'I am here2.'; echo 'You have not entered search details. Please go back and try again.'; exit; } if (!get_magic_quotes_gpc()) { echo 'I am here3.'; $searchtype = addslashes($searchtype); $searchterm = addslashes($searchterm); } echo 'I am here4.'; @ $db = new mysqli('localhost', 'bookorama', 'bookorama123', 'books'); echo 'I am here5.'; if (mysqli_connect_errno()) { echo 'I am here6'; echo 'Error: Could not connect to database. Please try again later.'; exit; } echo 'I am here7.'; $query = "select * from books where ".$searchtype." like '%".$searchterm."%'"; $result = $db->query($query); $num_results = $result->num_rows; echo 'I am here8.'; echo "<p>Number of books found: ".$num_results."</p>"; for ($i=0; $i <$num_results; $i++) { $row = $result->fetch_assoc(); echo '<p><strong>'.($i+1).'. Title: '; echo htmlspecialchars(stripslashes($row['title'])); echo '</strong><br />Author: '; echo stripslashes($row['author']); echo '<br />ISBN: '; echo stripslashes($row['isbn']); echo '<br />Price: '; echo stripslashes($row['price']); echo '</p>'; } echo 'I am here9.'; $result->free(); $db->close(); echo 'I am here10.'; ?> </body> </html> And the database: *************************** 1. row *************************** isbn: 0-672-31509-2 author: Pruitt, et al. title: Teach Yourself GIMP in 24 Hours price: 24.99 *************************** 2. row *************************** isbn: 0-672-31697-8 author: Michael Morgan title: Java 2 for Professional Developers price: 34.99 *************************** 3. row *************************** isbn: 0-672-31745-1 author: Thomas Down title: Installing Debian GNU/Linux price: 24.99 *************************** 4. row *************************** isbn: 0-672-31769-9 author: Thomas Schenk title: Caldera OpenLinux System Administration Unleashed price: 49.99 4 rows in set (0.02 sec) Sorry about that ...
  6. I am starting out on PHP/MYSQL using the book "PHP and MYSQL Web Development" and I'm having trouble running this code: <html> <head> <title>Book-O-Rama Search Results</title> </head> <body> <h1>Book-O-Rama Search Results</h1> <?php error_reporting(E_ALL) ; ini_set('display_errors',1); ?> <?php // create short variable names echo 'I am here1.'; $searchtype=$_POST['searchtype']; $searchterm=trim ($_POST['searchterm']); if (!$searchtype || !$searchterm) { echo 'I am here2.'; echo 'You have not entered search details. Please go back and try again.'; exit; } if (!get_magic_quotes_gpc()) { echo 'I am here3.'; $searchtype = addslashes($searchtype); $searchterm = addslashes($searchterm); } echo 'I am here4.'; @ $db = new mysqli('localhost', 'bookorama', 'bookorama123', 'books'); echo 'I am here5.'; if (mysqli_connect_errno()) { echo 'I am here6'; echo 'Error: Could not connect to database. Please try again later.'; exit; } echo 'I am here7.'; $query = "select * from books where ".$searchtype." like '%".$searchterm."%'"; $result = $db->query($query); $num_results = $result->num_rows; echo 'I am here8.'; echo "<p>Number of books found: ".$num_results."</p>"; for ($i=0; $i <$num_results; $i++) { $row = $result->fetch_assoc(); echo '<p><strong>'.($i+1).'. Title: '; echo htmlspecialchars(stripslashes($row['title'])); echo '</strong><br />Author: '; echo stripslashes($row['author']); echo '<br />ISBN: '; echo stripslashes($row['isbn']); echo '<br />Price: '; echo stripslashes($row['price']); echo '</p>'; } echo 'I am here9.'; $result->free(); $db->close(); echo 'I am here10.'; ?> </body> </html> The program only goes as far as "I am here4" ... and nothing happens. I don't get any errors, just a blank screen. Is it unable to gain access to the database? This is the database: *************************** 1. row *************************** isbn: 0-672-31509-2 author: Pruitt, et al. title: Teach Yourself GIMP in 24 Hours price: 24.99 *************************** 2. row *************************** isbn: 0-672-31697-8 author: Michael Morgan title: Java 2 for Professional Developers price: 34.99 *************************** 3. row *************************** isbn: 0-672-31745-1 author: Thomas Down title: Installing Debian GNU/Linux price: 24.99 *************************** 4. row *************************** isbn: 0-672-31769-9 author: Thomas Schenk title: Caldera OpenLinux System Administration Unleashed price: 49.99 4 rows in set (0.02 sec)
  7. Hello, I'm very new to php, so I apologize for the primitive nature of this question. I am using php's mail() function to send an email to myself with no success. Part of my code looks like this: $toaddress = "pedestrian@sidewalklyrics.com"; $fromaddress = "From: webserver@example.com"; $subject = "Feedback from web site"; $mailcontent = "Customer name: ".$name."\r\n". "Customer email: ".$email."\r\n". "Customer comments: ".$feedback."\r\n"; mail($toaddress, $subject, $mailcontent, $fromaddress); My php.ini file looks like this: [mail function] ; For Win32 only. SMTP = localhost smtp_port = 25 ; For Win32 only. ; sendmail_from = pedestrian@sidewlaklyrics.com But I only get a warning: Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files\Apache Group\Apache2\htdocs\processfeedback.php on line 16 Would you happen to know what the problem is? ~P
×
×
  • 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.