Jump to content

Bman900

Members
  • Posts

    184
  • Joined

  • Last visited

    Never

Everything posted by Bman900

  1. I was writing a blog system and when I got to the date stamp it comes out as 2010-01-20 and I want it as 01/11/2010. I did directly insert this with phpmyadmin because I did not get to the point where I have a back end for this. But how would I insert this into a query with php?
  2. Hi there, I am still learning here and I just have a quick question about this code here: <html> <input type="text" id="firstname" name="firstname" /> </html> What is the point of the "id" tag? I have been watching some tutorials and they seem to just skip that and only set the type and use the name attribute. Thanks in advance.
  3. I am reading a PHP book right now and am on the part where you make a connection to a database. Here is the code am looking at: <?php $dbc = mysqli_connect('host', 'username', 'password', 'databasename') or die('Error Connecting to MySQL server.'); ?> Now they tell me I don't have to close my first line statement as "or die" is still part of that said statement. But here is where they confuse me. This is the code where they tell me to run my query at: <?php $result = mysqli_query($dbc, $query); // they close the statement here and bellow or die('Error quering database'); ?> Wouldn't it be the same case here as "or die" is still part of my statement so technically I would not need to close the first line, right? Sorry I know this is kind of lame but I want to learn something right the first time and I go deep into the lessons by rewriting code several times to remember it and I don't want to learn it the wrong way. Thanks:)
  4. I solved it why. When I send the emails it losses the list because it refreshes the screen. If I put this in a session and call for it in the same page so when it refreshes, will it solve my problem?
  5. Ok am making this a bit more complicated. It worked as mentioned above but I want more. The emails won't send out when I add the following: <?php if($category == "All") { $result = mysql_query("SELECT email FROM newsletter ORDER BY id"); } else { $result = mysql_query("SELECT email FROM newsletter WHERE category ='$category' ORDER BY id"); } ?> Instead of this: <?php $result = mysql_query("SELECT email FROM newsletter ORDER BY id"); ?> Also here is my email code: <?php foreach($list as $email) { mail($email, $subject, $message,"From: $from_email\n" . "MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1"); print "<br>$email\n"; flush(); } ?>
  6. Ok now am confused. You guys are talking about the [] after the $list right?
  7. <?php $result = mysql_query("SELECT email FROM newsletter ORDER BY id"); while($row = mysql_fetch_assoc( $result )) { echo "".$row['email'].", "; } ?> This prints a list like A@yahoo.com, b@yahoo.com, c@yahoo.com, which is perfect as I want to send out emails to those people but I need them in a variable such as $email to use with the mailer function. So how would I populate that list into a single variable?
  8. Wow thank you! I can't beleive I missed that!
  9. Here is the code: <?php $category = $_POST['category']; echo "$category"; if($category = "All") { $result = mysql_query("SELECT email, category FROM newsletter ORDER BY id"); } else { $result = mysql_query("SELECT email, category FROM newsletter WHERE category ='$category' ORDER BY id"); } ?> <table width="500" border="2" cellspacing="0" cellpadding="0"> <tr> <th>Email</th> <th>Category</th> </tr> <?php while($row = mysql_fetch_assoc( $result )) { echo "<tr>"; echo "<td>".$row['email']."</td>"; echo "<td>".$row['category']."</td>"; echo "</tr>"; } ?> </tr> </table> For some of reason even when $category is NOT All it still runs that statement rather than the else. Can any one spot any errors that can solve this? Oh and am only echoing category to check if it is passed along correctly which it is.
  10. Ok lets say I have the following: email | category b@h.com A a@b.com A m@h.com B How do I select and display entries where the category is A only?
  11. Ok something is not going right because I am not passing on the value of the selection. Here is new new simplified code: <?php mysql_connect("db2075.perfora.net","dbo300131695","WKPRzTpp"); mysql_select_db("db300131695"); if(isset($_POST['submit'])) { $category=$_POST['category']; echo "$category"; } ?> <form id="form1" name="form1" method="post" action="<? $PHP_SELF; ?>"> <select name="category"> <option>Brazilian Jiu-Jitsu</option> <option>Krav Maga</option> </select> <label> <input type="submit" name="Submit" value="Submit" /> </label> </form>
  12. At this point I just want to print the result for now. Later on I will send emails out to people on that list.
  13. I made up something like this but it doesn't actually post anything: <?php if(isset($_POST['submit'])) { $category=$_POST['category']; $result=mysql_query("select email from $category where category= '$category'") or die (mysql_error()); if(mysql_num_rows($result)) { while($row = mysql_fetch_row($result)) { print("<option value=\"$row[0]\">$row[0]</option>"); } } else { print("<option value=\"\">No email in there yet</option>"); } } ?> <form id="form1" name="form1" method="post" action="<? $PHP_SELF; ?>"> <select name="category"> <option>Brazilian Jiu-Jitsu</option> <option>Krav Maga</option> </select> <label> <input type="submit" name="Submit" value="Submit" /> </label> </form>
  14. So I have the following table: newsletter And than I have two categories: email and category I want to have a drop down menu where I can select which category of emails I want to display and send. I have never worked with a drop down menu in PHP so any help would be great.
  15. I have this in php4: <?php $root = $_SERVER['SERVER_NAME']; $url = $_SERVER['PATH_INFO']; $adminregister = str_replace("admin/admin.php","register.php",$url); echo "http://www.$root$adminregister"; ?> How can this be rewritten to work in PHP5?
  16. I tried to search for include_path setting in my php.ini and no luck.
  17. See I thought about that but if I create scripts later on I want them to be placed any where on a server and not just a folder I require.
  18. Yes I actually tried four dots, nothing is working...........
  19. include('./file.php'); or include('../file.php'); I have to scripts that both use the include function. 1. root/pandora/include/contants.php which includes <?php include ("./include.php"); ?> Than I have root/demo/admin/admin.php which includes <?php include("../include/session.php"); include("../include.php"); include("../config.php"); ?> In both of those scripts I need to go back one folder. In the first one it only work with one . while in the other one it only work with two . Here are the errors I get: First script if I add the two dots: Warning: include(../include.php) [function.include]: failed to open stream: No such file or directory in /home/balint/public_html/pandora/include/constants.php on line 2 Warning: include() [function.include]: Failed opening '../include.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/balint/public_html/pandora/include/constants.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/balint/public_html/pandora/include/constants.php:2) in /home/balint/public_html/pandora/include/session.php on line 50 Code at line 2: <?php include ("../include.php"); ?> Second script if I have only one dot errors: Warning: include(./include/session.php) [function.include]: failed to open stream: No such file or directory in /home/balint/public_html/demo/admin/admin.php on line 3 Warning: include() [function.include]: Failed opening './include/session.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/balint/public_html/demo/admin/admin.php on line 3 Warning: include(./include.php) [function.include]: failed to open stream: No such file or directory in /home/balint/public_html/demo/admin/admin.php on line 4 Warning: include() [function.include]: Failed opening './include.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/balint/public_html/demo/admin/admin.php on line 4 Warning: include(./config.php) [function.include]: failed to open stream: No such file or directory in /home/balint/public_html/demo/admin/admin.php on line 5 Warning: include() [function.include]: Failed opening './config.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/balint/public_html/demo/admin/admin.php on line 5 And to clarify here is the code on those line: <?php session_start(); include("./include/session.php"); include("./include.php"); include("./config.php"); ?> Any ideas why this behavior is happening?
  20. I have linux and installed apache/MSQL/ and PHP5. I downloaded my script that got a lot of errors on my shared host with PHP5. For some reason my localhost which runs PHP5 doesn't display the same errors. It does display errors but doesn't sinch up with the ones on my shared hosting. What could be the issues here?
  21. The afformentioned above uses absolute paths Alright so if I set up whatr you just said can I do what I described in my first post because I don't really get include('functions/xyz.func.php'); so basicly I set up that config file u showed my and do ("../inlcude/config.php"); Would that work like that?
  22. Or you could just echo the $_SERVER['DOCUMENT_ROOT'] variable yourself. I like that better since it is not server specific and if I need to deploy my project somewhere else, it works. Plus I have a server on my PC for testing there as well.
  23. Seee thats what I wanted. They way I did it in php4 was include ("../inlcude/config.php"); I noticed that your root folder is docs, stupidmquestion coming, Is that the same on all hosting? Take that stupid question away, I looked at it a bit more and see what you did.
  24. Well as we all know that if your inlcude file is in a directory above what you are in, you can not call a file with inlcude correctly. I need a way to fix this on shared hosting because not many people have dedicated hosting.
×
×
  • 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.