Jump to content

pourmeanother

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Male
  • Location
    California

pourmeanother's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Two weeks ago I was in the exact same boat trying to figure out how to use PHP and databases to have stuff posted on a website. A lot of the online tutorials will get you about halfway there - but they tend to be confusing for newcomers, or leave out what you're actually looking for beyond the basic understanding. I tried for a week to get it working, but no dice! I went out and ponied up $20 for "PHP & MySQL for Dummies" and I had my site running the next day. I think it's worth the investment to just pick up a decent book on this stuff and walk through it. Since buying it I've implemented a site that takes information from forms and automatically posts it on a website. It displays the average of certain items in the database, and can allow search functions. Now I'm moving on to password protecting pages on my site so people have to register to view them. If you don't have $20 to spare-- try "w3schools" or "tizag", but I think your best bet is a book.
  2. Just to further check, implement like this given the code in the O.P.? <?php //....continued..... elseif( substr($value, strpos($value, '@')) !== '@aol.com' ) { $message[]="$value is not an AOL email address"; } ?>
  3. PHP4 Let's say I want to verify an email a user enters with their registration to see if it's from a specific site. Example: let's say I only want users to register using an AOL email address (user@aol.com), how would I check for the '@aol.com' ending? <?php //...continued from code above.... if(eregi("email", $field) { if(!ereg("^.+@.+\\..+$", $value)) { $message[]="$value is not a valid email address"; } elseif(______________) { $message[]="$value is not an AOL email address"; } } ?> Please fill in the blank. Also, let me know if everything checks out for PHP4; I've had to convert after using PHP5. THANKS!
  4. I have the following code which I expect to display the average of the column named "column" from the table "tableone". Instead I get an output of "Resource id #2" (if column is the 2nd column). <?php $host="localhost"; $user="user"; $password=""; $database="databasename"; $cxn = mysql_connect($host, $user, $password) or die(mysql_error()); $db_selected = mysql_select_db($database); if(!$db_selected) { exit("Could not connect"); } $query = "SELECT AVG('column') FROM tableone"; $result = mysql_query($query, $cxn); if(!$result) { echo "N/A"; } else { echo "<b>Average of column:</font> $result</b><br>"; } mysql_close($cxn); ?>
  5. I did a little more digging, and found that I needed to replace 'localhost' with 'mysql'. Upon doing that, the output was exactly as desired. Thanks for the help, I may be back just yet
  6. "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (46)" Which I'm assuming has something to do with my setup (or lack of)? Not sure how to resolve that...
  7. Thanks for the prompt reply. Tried changing that, same output. ???
  8. Using the following code I receive "Error" as the output -- meaning I'm not successfully connecting to the MySQL server. PHP4 mysql server version 4.1.14 phpMyAdmin 2.11.9 MySQL client version 3.23.49 (Not sure which of the above is required information) <?php $host="localhost"; $user="user"; $password=" "; $database="databasename"; $cxn = mysql_connect($host, $user, $password); if(!$cxn) { exit("Error"); } $db_selected = mysql_select_db($database); if(!$db_selected) { exit("Could not connect"); } $query = "SELECT * FROM AdamsChristen"; $result = mysql_query($query, $cxn); if(!$result) { exit("Data currently unavailable"); } while( $row = mysql_fetch_assoc($result) ) { extract($row); echo "<table cellspacing='15'>"; echo "<tr><td colspan='5'><hr></td></tr>\n"; echo "<tr> <td>$semester$year</td> <td><b>Helpfulness:</b>\n$helpfulness</td> <td><b>Ease of Grading:</b>\n$grading</td> <td><b>Attention Factor:</b>\n$interesting</td> <td><b>Attendance Mandatory:</b>\n$attendance</td> <td><b>Comments:</b>\n$comments</td> </tr>\n"; echo "<tr><td colspan='5'><hr></td></tr>\n"; } echo "</table>"; mysql_close($cxn); ?> Trying to troubleshoot. All help is appreciated!
  9. Thanks for the link. I was hoping to take the free route here I'm personally putting a lot of money into this-- but I bit the bullet and went and bought a PHP/MySQL book. Now I'm not so helpless as in my initial post. Could you guys look this over and see if I'm on the right track. The following code is designed to pull data from a table called "FirstnameLastname" under the database "databasename" and display it on a page. <?php $connect = mysqli_connect("localhost", "account", "password", "databasename") or die("Error"); $query = "SELECT * FROM LastnameFirstname"; $result = mysqli_query($connect, $query) or die("Couldn't retrieve data"); while( $row = mysqli_fetch_assoc($result) ) { extract($row); echo "<table>"; echo "<tr><td><hr></td></tr>"; echo "<tr>\n <td>$semester, $year</td>\n <td>"Comments:"\n$comments</td>\n </tr>\n"; echo "<tr><td colspan='2'><hr></td></tr>\n"; } echo "</table>\n"; mysqli_close($connect) ?> Once I have this fixed, I need to work out submitting a form and having the form data transferred to the appropriate tables in the database. I guess I'm working backwards, for some reason
  10. I am an absolute beginner when it comes to PHP, SQL, and the like-- and I'm thrust into a task that I just can't figure out. I am downloading the PHP 5.2.6 version onto my Windows computer right now. I have a domain and webhosting with MySQL capabilities.... What I want to do is have a form on a page, and have the information submitted via the form automatically posted on the same page. There's other more detailed specifics, but having the form post is the basic concept I'm trying to figure out (the other stuff I can work on later). I was told I need to use PHP to interpret the information, pass it to a MySQL database, and then call the information from the database to have it posted. Being the total noob that I am I have absolutely zero idea of how to do that. I've researched about every PHP tutorial I could find on google to no avail (most of them are incomplete and leave out important descriptions, confusing for beginners, or specifically teach how to have contents of the form emailed to me- whereas I'm looking for how to post them). --------------- If somebody could help explain everything in a detailed way that a 5 year-old would understand, that would be GREATLY appreciated. Any relevant links, sample codes, or your own concepts would be solid. Thanks guys, appreciate the help.
×
×
  • 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.