premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
<?php $currentYear = date("Y"); for ($year=$currentYear;$year>($currentYear-20);$year++) { echo $year . "<br />"; } ?> Should do it.
-
I am not sure if there is a better way to do it, I am sure there is but this would work: preg_match('/(^[0-9]*)/i', $user, $matches); if ($matches[1] != $user) return array(false, "Username must contain at least 1 Numeric (123) character.");
-
[SOLVED] My Code Won't UPDATE the Database -- NEEDED ASAP
premiso replied to skiingguru1611's topic in PHP Coding Help
A few questions, where are those variables coming from? A form? If so you should really be escaping the data with mysql_real_escape_string. You should also access them with $_POST or $_GET. The or die(mysql_error); should be added after the mysql_query click on the links I posted for examples. -
Your not filtering the post input. If a person knows your host structure they can basically read any file on your server with that script. I would suggest validating the url input to avoid this issue.
-
[SOLVED] Building a Simple Search Feature on a Website
premiso replied to limitphp's topic in PHP Coding Help
where band LIKE '%$query%' Use the like operator. You probably want to split the incoming data at the space and then use that as keywords. Just an fyi. -
There is no kitty like a drunk kitty!
-
Could you clarify this? The end user only see's one column populated in the dropdown. I can't seem to work out why we're calling on two as per the query. I know this is the correct way but I just don't understand it. @Mchl: Ah, I see. Very neat indeed. Still at the dropdown junction though You pull 2, the display value then the passed value which is usually an id. This is common practice.
-
Use parenthesis to group it, just like math. Order of Operations. So if (x and x) OR (x and y) return the results.
-
You need a semi colon after this line: ftp_chdir($ftp_connect, "/u/ssc/price/");
-
[SOLVED] Sending email; variables not displaying.
premiso replied to Zylvyn's topic in PHP Coding Help
Yes, but this was known since 2002, programmers just cannot write books very well. The issue of register_globals is just really sinking in and being acted on. -
send current date and time to mysql datetime field
premiso replied to s_ainley87's topic in PHP Coding Help
Obviously that will not work, look at the format. $date = date("Y-m-d H:i:s") It should enter properly using that. -
[SOLVED] Sending email; variables not displaying.
premiso replied to Zylvyn's topic in PHP Coding Help
You need to use $_POST['formfieldname'] to access them. -
You would use Javascript or AJAX. PHP cannot do this alone. And a tip, let go of the shift key, no one likes titles in all caps.
-
Ummm.... $query = "SELECT message, terms FROM xxx WHERE MATCH (terms) AGAINST (message)"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { echo "Terms : {$row['terms']}<br>"; } That is how you would do it...
-
mysql_query("INSERT INTO xxx (name, message, created) VALUES ('$name', '$message', NOW()) SELECT message, terms FROM xxx WHERE MATCH (terms) AGAINST (message)") or die(mysql_error()); to mysql_query("INSERT INTO xxx (name, message, created) VALUES ('$name', '$message', NOW())"); $query = "SELECT message, terms FROM xxx WHERE MATCH (terms) AGAINST (message)";
-
Easy, you just use the timestamp to pull up the month you want.
-
i'm not matching words in query, i'm trying to match any word in the user submitted 'message' field with any word (over 4 chars) in the 'text' field. Gotcha, so you are using single quotes around the message field being returned from the form? You also need to separate the INSERT and SELECT query. You have them as one. Separate t out ad see what happens.
-
How many rows do you have in your db? Also you need single quotes around terms and messages. If you have less than 5 fields and at least 3 of those fields have terms or messages in it, that will not return them. Fulltext indexing has that as a rule, if the results return 50% of the rows, no rows are returned. I would read up on the full text so you know what to expect.
-
Your better off using a CRON job or Scheduled task for this. PHP is not meant to do this type of stuff.
-
[SOLVED] Why isn't this working? Am I missing something?
premiso replied to Chubichan's topic in PHP Coding Help
Like this: <?php $conn = mysql_connect($dbhost, $dbuser, $dbpass); mysql_select_db($dbname) or die ('Error connecting to mysql'); ?> Did you try it? Yes, like that. -
[SOLVED] Why isn't this working? Am I missing something?
premiso replied to Chubichan's topic in PHP Coding Help
use mysql_select_db after mysql_connect -
[SOLVED] Help Needed to separate a value into different variables
premiso replied to patheticsam's topic in PHP Coding Help
What do you mean split those felds into different variables? When you post the form? Add a : inbetween them, then on form processing use split or explode it at : to put the different values into an array and access by index of 0 or 1. -
http://us.php.net/manual/en/function.ziparchive-close.php Found that, use that instead.
-
You want url rewriting. I would look into that. robots.txt will not fix this.
-
[SOLVED] Why isn't this working? Am I missing something?
premiso replied to Chubichan's topic in PHP Coding Help
You know pritnig out the actual error message may help. <?php if(isset($_POST['submit'])) { include 'config.php'; include 'opendb.php'; $home = $_POST['home']; $mot = $_POST['mot']; $pf = $_POST['pf']; $fi = $_POST['fi']; $loc = $_POST['loc']; $con = $_POST['con']; $ms = $_POST['ms']; $dis = $_POST['dis']; $query = "INSERT INTO cms (home, team, form, financial, location, contact, mission, disclaimer) VALUES ('$home', '$mot', '$pf', '$fi', '$loc', '$con', '$ms', '$dis')"; mysql_query($query) or die('No worky: ' . mysql_error()); include 'closedb.php'; echo "Worky!"; } ?> mysql_error would help you. My bet is you have a ' single quote in your data coming in and mysql_real_escape_string that data will probably fix it.