Jump to content

per1os

New Members
  • Posts

    3,095
  • Joined

  • Last visited

Everything posted by per1os

  1. Magic_quotes is off than I would suggest using www.php.net/mysql_real_escape_string instead of add slashes. Also you should never have to strip_slashes of data coming out of a database. Because once the escaped data enters the DB MySQL automatically removes those slashes for you. Striping the data does not adverse affects until you have \ in your code, than stripslashes will make sure that goes away.
  2. $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'pass'; $dbname = 'database1'; $dbname2 = 'database2'; $dbpass2 = 'dbpass2'; $dbuser2= 'dbuser2'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $conn2 = mysql_connect($dbhost, $dbuser2, $dbpass2) or die ('Error connecting to mysql'); mysql_select_db($dbname, $conn); mysql_select_db($dbname2, $conn2); // here s the website mysql_query($query, $conn); mysql_query($query, $conn2); mysql_close($conn);
  3. http://us.php.net/manual/en/ref.mail.php#75663
  4. You should never have to stripslashes coming out of the database. If you are it means that you double escaped the data going into the database. www.php.net/get_magic_quotes_gpc Use that to determine if the data is already escaped. If that is true it means slashes were already added to the data via addslashes. But yea, rule of thumb is you should never use stripslashes on data coming out of a database.
  5. Yep it is.
  6. while($request=mysql_fetch_array($query_return)) { $rand_num = rand(100000000, 999999999); // random nrs mysql_query("UPDATE `user` SET user_random = " . $rand_num . " WHERE user_id = " . $request['user_id'] . " LIMIT 1;"); } Whats one way to do it, inefficient but it works.
  7. Came from my php.ini, you should have a table like that. Also my "Configure Command" looks like this: Notice the --with-mysql portion, I do not think that is required because I know that the one I run locally was not compiled with that command but yea. I should also note i am running PHP 4.4.x
  8. Create a file, showimage.php or something like that. Bass the image name via get and pull the file from the db and for the img tag use this: <img src="showimage.php?image=test.jpg" /> The showimage.php file should produce proper headers and use the readfile() command. see www.php.net/headers not the user comments, as this has been done many times in there.
  9. create a file called phpinfo.php <?php phpinfo(); ?> That will tell you where the php.ini file is coming from. Wherever that says search the directory and locate it and either A delete it or B make it the same as the one you modified in your php folder. The undefined function error call means that the mysql or mysqli extensions have not been either uncommented (removing the or added under the extension portion of the php.ini file.
  10. Post your actual code that you are using this function for.
  11. Books are nice, but are not "real" world. Yes, even though it states in C:\windows as long as there is not a php.ini file located there the one in the php directory is the one to modify. Having both active in php.ini does not matter one way or the other. As long as mysqli is uncommented it should work, you may need to restart apache for the settings to take affect. mysql_connect is nearly the same as mysqli_connect, just an older version with minor differences. mysqli is more efficient as it is the newer and latest/greatest version. mysqli and mysql are the same thing basically.
  12. Does gender print out? Have you tried printing out gender in the if statements? Have you tried just != instead of !== ? Given the code above, it should work unless foul play is coming about like for some reason the data is not being posted? Post more code is the gist of it.
  13. You have been helped dude. The last 2 posts are exactly what you want. If mpharos gives an error POST the whole error message, including the line. Understand that they have helped, whether you can get it to work or not is another question. Their reply's are valid and the logic is correct. With a reply like that I would doubt anyone would want to help you anymore, you may have just lost all chances by doing that crap.
  14. <?php function gender() { global $poster, $error; $gender = $_POST['gender']; // set it here if (isset($poster)) { if (!ctype_alpha($gender)) { echo "<li>error-1!</li>"; $error++; } elseif ($gender !== "male" || $gender !== "female") { echo "<li>error-2!</li>"; $error++; } } } ?> I would do that or pass it as a parameter to the function: <?php $gender = $_POST['gender']; echo $gender . " gender<br />"; // make sure it is being populated right echo gender($gender); // run the function function gender($gender) { global $poster, $error; if (isset($poster)) { if (!ctype_alpha($gender)) { echo "<li>error-1!</li>"; $error++; } elseif ($gender !== "male" || $gender !== "female") { echo "<li>error-2!</li>"; $error++; } } } ?>
  15. <?php /* Program: mysql_up.php * Desc: Connects to MySQL Server and * outputs settings. */ echo "<html> <head><title>Test MySQL</title></head> <body>"; $host="localhost"; $user=""; $password=""; $cxn = mysql_connect($host,$user,$password); $sql="SHOW STATUS"; $result = mysql_query($sql); if($result == false) { echo "<h4>Error: ".mysqli_error($cxn)."</h4>"; } else { /* Table that displays the results */ echo "<table border='1'> <tr><th>Variable_name</th> <th>Value</th></tr>"; for($i = 0; $i < mysql_num_rows($result); $i++) { echo "<tr>"; $row_array = mysql_fetch_row($result); for($j = 0;$j < mysql_num_fields($result);$j++) { echo "<td>".$row_array[$j]."</td>\n"; } } echo "</table>"; } ?> </body></html> www.php.net/mysql_connect Nearly the same usage except without using i you are not required to put the connection string in the function. php.ini file is usually searched for in C:\Windows C:\Windows\System32 C:\php In an order similiar to that. If it is not found in windows it searches system32 etc. It is just automatic. Generally you should change them all if they are located in those locations if you make a modification. Or remove the 2 you do not want to use. MySQLi I believe is compiled with PHP5 only, but if not it should be inside there as an extension of ;extension=php_mysqli.dll remove the ; from that line to allow it and you may have to restart apache.
  16. <?php $gender = $_GET['gender']; function gender() { global $gender, $poster, $error; if (isset($poster)) { if (!ctype_alpha($gender)) { echo "<li>error-1!</li>"; $error++; } elseif ($gender !== "male" || $gender !== "female") { echo "<li>error-2!</li>"; $error++; } } } ?> Try that you are assuming register_globals is on which chances are it is not, and if it is it shouldnt be due to security risks.
  17. I would not do the or die on mysql_num_rows, not necessary. Basically check the data in the database for the username you are entering. Also I would use $sql instead of $query in the first or die portion. Give that a try and see what happens. I would also print out $user to make sure it is what you expected.
  18. I do not think there is a function to handle this type of stuff. You may try the base64 decode with www.php.net/readfile to display it/download it. www.php.net/headers for more examples on the readfile/download.
  19. http://www.dynamicdrive.com/dynamicindex1/ http://www.dynamicdrive.com/dynamicindex1/combodescribe.htm http://www.dynamicdrive.com/dynamicindex1/anylinkvertical.htm Basically browse that page till you find the one you want. Googled DHTML Navigation to find those results. P.S.: You would get better help on this subject by posting in the Javascript forum, as it is a javascript question.
  20. Your recollection would be correct if you wanted the person to select 1 or more checkboxes. It seems to be as though you only want them to select one. As metrostars pointed out rename it to time_horizon and it should work. Also you may want to witch to radio buttons if that is the case, I am not sure if renaming the fields all the same will allow for multiple checks or not, but I know with radio buttons naming them all the same will allow the user to only choose one.
  21. $currentdate = date("Y-m-d", (time()+3600*24)); $selects = "SELECT * FROM vehicles WHERE available < $currentdate"; Try that. the 3600 = 1 hour in seconds, times it by 24 to simulate tommorow. Time returns a unix timestamp.
  22. www.google.com www.webmonkey.com www.dhtml.com Simple searching?
  23. Remove the single quotes from available and $currentdate in the SQL.
  24. I like the int(11) for the unix timestamp. Just personal preference.
  25. You are on the right track as it seems to me. Give it a try.
×
×
  • 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.