Jump to content

metalblend

Members
  • Posts

    89
  • Joined

  • Last visited

    Never

Everything posted by metalblend

  1. metalblend

    FIELDS

    It looks like you already have an auto_incriment field.
  2. you\'re going to kick yourself. if you tab your code you\'ll see you\'re missing a } here\'s the \"repaired\" code:[php:1:252e080791]<?php //check to see if Username, email, and password have values if(empty($password) || empty($email)) { if(empty($password)) { print \"Sorry, your password CANNOT be blank.. please try again<BR>\"; } if(empty($email)) { print \"Sorry, your email CANNOT be blank.. please try again<BR>\"; //if its passed the check update their information } else { mysql_query(\"UPDATE users SET password=\'$password\' WHERE username=\'$username\'\"); } } ?>[/php:1:252e080791] ALWAYS TAB YOUR CODE Hope that helps.
  3. lol .. Glad you got it worked out.
  4. http://code.phirebrush.com/ref/form01 index.html: <form method="post" action="handle_form.php"> <p>First Name <input type="text" name="firstname"> </p> <p>Last Name <input type="text" name="lastname"> </p> <p>EMail Address <input type="text" name="email"> </p> <p>DOB <input type="text" name="dob"> </p> <p>Info <textarea name="info"></textarea> </p> <p> <input type="submit" value="Submit"> </p> </form> handle_form.php:[php:1:9b6ade3a63]<?php //Get POST Variables $firstname = $HTTP_POST_VARS[\'firstname\']; $lastname = $HTTP_POST_VARS[\'lastname\']; $email = $HTTP_POST_VARS[\'email\']; $dob = $HTTP_POST_VARS[\'dob\']; $info = $HTTP_POST_VARS[\'info\']; //Connect to the database $link = mysql_connect($host, $user, $password) or die(\"<code>Error: <i>\".mysql_error().\"</i></code>\"); mysql_select_db($dbName,$link) or die(\"<code>Error: <i>\".mysql_error().\"</i></code>\"); $q = mysql_query(\"INSERT INTO `\".$tableName.\"` (`firstname`,`lastname`,`email`,`dob`,`info`) VALUES (\'\".$firstname.\"\',\'\".$lastname.\"\',\'\".$email.\"\',\'\".$dob.\"\',\'\".$info.\"\')\",$link) or die(\"<code>Error: <i>\".mysql_error().\"</i></code>\"); mysql_close($link); header(\"Location: results.php\"); ?>[/php:1:9b6ade3a63] results.php:[php:1:9b6ade3a63]<?php $link = mysql_connect($host, $user, $password) or die(\"<code>Error: <i>\".mysql_error().\"</i></code>\"); mysql_select_db($dbName,$link) or die(\"<code>Error: <i>\".mysql_error().\"</i></code>\"); $q = mysql_query(\"SELECT * FROM `\".$tableName.\"` ORDER BY `id` DESC\",$link) or die(\"<code>Error: <i>\".mysql_error().\"</i></code>\"); //creat a table to show the table results in print \"<table border=1 width =\"100%\" cellspacing=2 cellpadding=2 align=center>n\"; print \"<tr align=center valign=top>n\"; print \"<td align=center valigntop>Name</td>n\"; print \"<td align=center valigntop>EMail</td>n\"; print \"<td align=center valigntop>DOB</td>n\"; print \"<td align=center valigntop>Comments/Info</td>n\"; print \"</tr>n\"; //fetch the results from the database while ($row = mysql_fetch_array($q)) { print \"<tr align=center valign=top>n\"; print \"<td align=center valign=top>\".$row[\'firstname\'].\" \".$row[\'lastname\'].\"</td>n\"; print \"<td align=center valign=top>\".$row[\'email\'].\"</td>n\"; print \"<td align=center valign=top>\".$row[\'dob\'].\"</td>n\"; print \"<td align=center valign=top>\".$row[\'info\'].\"</td>n\"; print \"</tr>n\"; } //close the link to the database mysql_close($link); print \"</table>n\"; ?>[/php:1:9b6ade3a63] Hope that helps.
  5. If you\'ve installed the latest version of PHP (4.3), you\'re working with register_globals off. On the handle page, add this to the beginning of the code:[php:1:8db01511b1]$Array = $HTTP_POST_VARS[\'Array\'];[/php:1:8db01511b1] You\'ll want to read up on working with register_globals off: http://www.php.net/manual/en/security.regi...sterglobals.php Hope that helps.
  6. Here\'s an easy way to do what you want.. http://www.oxyscripts.com/viewcode.php?id=12 I have a function similar to this one I\'ve made but it\'s a little more complicated than checking if a table exists. Hope that helps.
  7. You may want to refer to this thread: http://forums.phpfreaks.com/viewtopic.php?t=1946 Here\'s a solution you can use for this situation: Hope that helps.
  8. yes i\'m sure we all have used a variable in a query.. nothing fancy. see if there\'s an error in the query:[php:1:1527049cfd]$online_query = \"select buddy_name from \".$HTTP_SESSION_VARS[\'User\'].\"_buddies WHERE online= \'n\'\"; mysql_query($online_query) or die(\"Error : query failed.<br>MySQL said: <i>\".mysql_error().\"</i><br>rn\");[/php:1:1527049cfd] hope that helps.
  9. That will work.. or you can do it the dirty way: [php:1:a9971eb821]$online_query = \"select buddy_name from \".$HTTP_SESSION_VARS[\'User\'].\"_buddies WHERE online= \'n\'\";[/php:1:a9971eb821] Hope that helps.
  10. ..I\'m not sure what you can do to fix it. I just have to say, \"Wow.. that\'s horrible.\" Sorry..
  11. Yeah that\'s a good suggestion, but it\'d never work out completely. I\'ll start doing that whenever I ask questions.. whenever that is.
  12. ..well you definitely have more knowledge of classes than I do. I understand it but not to the point where I can recreate it.
  13. Here\'s what I got to work.. for Friday fun. function pbMySQL_query($str) { if(!isset($this->conn) || !isset($str)) { print "Error : argument(s) missing.<br>rn"; } else { $this->query = mysql_query($str,$this->conn) or die("Error : query failed.<br>rnmysql said: <i>".mysql_error()."</i><br>rn"); } } $db->pbMySQL_query("SELECT * FROM pbn_news ORDER BY id DESC"); if(isset($db->query)) { while($row=mysql_fetch_array($db->query)) { print "<div align=\'left\'>rn<div align=\'left\' style=\'background-color: #E0E0E0; padding: 2px;\'>rn".$row[\'name\']."<br>rn</div>rn".$row[\'message\']."<br><br></div>rn"; } }
  14. Aha! I knew there was a better way than using: $q=$db->pbMySQL_query(); Thanks again Palle.
  15. nevermind.. got it. When I used $query as a parameter, it conflicted with $this->query
  16. I\'ve been messing around with objects and classes lately and can\'t figure out why this wont work. I have index.php which uses the pbMySQL class (pbMySQL.class.php) and methods: include("lib/pbMySQL.class.php"); $db = new pbMySQL; $db->pbMySQL_open("localhost","user","pass"); $db->pbMySQL_useDB("database"); // $q=$db->pbMySQL_query("SELECT * FROM pbn_news ORDER BY id DESC"); $q=mysql_query("SELECT * FROM pbn_news ORDER BY id DESC"); if(isset($q)) { while($row=mysql_fetch_array($q)) { print $row[\'name\']."<br>rn"; } } else { print "query returned FALSE"; } $db->pbMySQL_close(); My problem is that when I use the first query method (which is commented; uses the pbMySQL_query() method) I do not get the mysql result returned, but if I use the same query without the method, I get the result. Here is the method from my class: function pbMySQL_query($query) { if(!isset($this->conn) || !isset($query)) { print "Error : argument(s) missing.<br>rn"; } else { $this->query = mysql_query($query,$this->conn) or die("Error : query failed.<br>rnmysql said: <i>".mysql_error()."</i><br>rn"); if(isset($this->query)) { return $this->query; } else { return FALSE; } } } The method returns FALSE and I don\'t understand why. Is it something in particular I have to do different when using a class? Any help is appreciated.. Thanks.
  17. The error looks like you\'re trying something like this: INSERT INTO tbl (name,url) VALUES (\'$name\',\'$url\',\'$other_var\',\'$possible_other_var\') ..where you say you\'re going to insert into 2 columns but give more than 2 values. Hope this helps.
  18. Ok here\'s some error checking.. I also noticed you had lots of typos. <?php // MySQL Connection Information $db_server = ""; // The name of your server $db_username = ""; // The MySQL username $db_password = ""; // The MySQL password $db_name = ""; // The name of the database where your forums are installed // Variables $tbl = "products"; // Name of the table where your topics are $url = "Site URL"; // The full URL to your forums $limit = "5"; // The amount of topics at max you want to be exported $model = "KFC" //Product Model Number #################################################### mysql_connect("$db_server","$db_username","$db_password"); mysql_select_db("$db_name"); $sql_topic = mysql_query("SELECT Model_No,Product_Name,FOB_Price,IMG FROM $tbl WHERE Model_No=\'$model\' ORDER BY Model_No DESC LIMIT $limit") or mysql_error(); if(!isset($sql_topic)) { print "Error : query failed.<br>rn"; } else { $cnt=mysql_num_rows($sql_topic); if($cnt<1) { print "Error : mysql returned 0 results.<br>rn"; } else { while($row=mysql_fetch_array($sql_topic)) { print "<img src=\'".$url."/".$row[\'IMG\']."\' border=\'0\'><br><a href=\'".$row[\'Model_No\']."\' target=\'_self\'>".$row[\'Product_Name\']."</a><br>".$row[\'FOB_Price\']."<br><br>rn"; } } } mysql_close(); ?>
  19. Try this: [php:1:c1dd6b2877]... $sql_topic = mysql_query(\"SELECT t.Model_No,t.Product_Name,t.FOB_Price,t.IMG FROM $tbl t WHERE t.Model_No=\'$model\' ORDER BY Model_No DESC LIMIT $limit\") or mysql_error(); ...[/php:1:c1dd6b2877]
  20. $q=mysql_query("SELECT * FROM table WHERE Model_No=\'KFC\' ORDER BY Model_No DESC"); Hope that helps.
  21. This is a complete guess, but have you tried connecting to \"www.lycos.com\" ?
  22. ..just as I replied in the PHP Help forum, you need to use PHP\'s mysql_query(). mysql_query("INSERT INTO `user` (`userid`, `forename`, `surname`, `fav_tabs`, `fav_quote`) VALUES (\'\', \'Jamie\', \'Guthrie\', \'GreenDay\', \'howdy\')",$db); Hope that helps.
  23. You can also use error_reporting(E_ALL) ..I think it\'s E_ALL .. correct me if I\'m wrong.
×
×
  • 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.