AyKay47
Members-
Posts
3,281 -
Joined
-
Last visited
-
Days Won
1
Everything posted by AyKay47
-
there are a few ways that this can be done..you can have the link hidden until the customer data has been added to the database, i would recommend doing this with jquery. You can also have the link present, but have it disabled until the customer data is submitted, again you can do this with either jquery or javascript...or even CSS..depends what route you want to go
-
you would want something like this perhaps.. $attractions = "3 | 6 | 7 | 10"; $explode = explode(" | ", $attractions); foreach($explode as $value){ //separate each id // do whatever with each id } I'm not 100% following you on this one, but the code above will split each id into a value of the $explode array, then will isolate each id with a foreach loop so you can do what you want with each...
-
then you should be able to do this the way that you intended, need to change the concatenation a little...and make sure that your variable is printing out what is expected.. while ($row = mysqli_fetch_array($result)) { echo "<img src=urbanimage.php?Ref={$row['image']}>"; }
-
not sure exactly what you are trying to do here, are you saying that when a user clicks on one of the links, you want them to be directed to index.html with the data of the link that they clicked on?
-
Get results of rows that aren't in other results
AyKay47 replied to imperium2335's topic in MySQL Help
at first glance your syntax looks correct here, do you receive any Mysql errors when debugging with mysql_error? -
what you are doing is using a url as the source, what you need to be doing is saving the file path to your db, then using that as the source.. eg.. $file_path = some/directory/to/file.jpg; // this should be in your db while ($row = mysqli_fetch_array($result)) { $file_path = $row['file_path']; //same as above, grabbing value from db and use it as img src echo "<img src=$file_path />"; }
-
you need to be wrapping your indices in quotes.. $username = $_GET[user]; should be $username = $_GET['user']; //$_GET is associative and the index needs to be wrapped in quotes unless its an integer
-
this guy has some pretty good tuts for beginners... http://www.youtube.com/results?search_query=phpacademy+form&aq=f
-
would you mind pasting the code to this thread please.
-
Validating email with regular expressions(preg_match)
AyKay47 replied to borisboris's topic in Regex Help
yeah you have the syntax a little off here, not a big deal... $good_email = "~^([a-zA-Z0-9]+@[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+)$~"; if (preg_match($good_email, $email)) { echo $email." is a valid email address.<br>"; } however this pattern will allow for non-emails... perhaps something like this instead for the pattern.. $good_email = "~^([a-zA-Z0-9]+@[a-zA-Z0-9_-]+\.[a-z]{2,3})$~"; -
i overlook the simple things sometimes...
-
getting the number in "blah blah REFERENCE ID: [526] blah blah"
AyKay47 replied to ultrus's topic in Regex Help
I don't think I agree with this approach. Firstly, $matches[0] will contain the full pattern match. According to your regex, you should be looking at $matches[1]. Also, there's really no need for a lot of that stuff.. like the anchor tags, the last .*, or those modifiers, based on your regex. Also, if you're just going to assume there's no other numbers in $subject, no need even for the first .* IOW based on your assumptions, You could just do '~\[(\d+)~'. Also \d technically matches more than straight numbers... But on that note..more importantly, that pattern is going to grab the first set of numbers preceded by a [ found in $subject, so it's not going to return the desired number if for instance $subject = "blah [123] more blah REFERENCE ID: [526] blah blah";. But I blame the OP for not being more specific with examples of what he's trying to get the number from. I think at a minimum, a pattern more like this should be used: ~REFERENCE ID: \[\K[0-9]+~ and then look at $matches[0] but..I think it would be "safer" if the OP were to give more details about he $subject he's trying to parse, actually show some real example(s). I agree with you on this CV, there are definitely better ways of approaching this...but from the OP's vague question and poor example...I threw something together quick that would work for him. If he had given me a better example, I would have created a more precise regex here...however thank you for pointing this matter out to both he OP and me -
you cannot have spaces in the url, you will need to encode these values using urlencode or rawurlencode or, better yet, change the method to POST
-
did you see this post earlier...I addressed this
-
<?php echo "<center>"; $username = $_GET['user']; //very top if(isset($username) { //if there trying to view a profile //gets the user name and makes it safe //querys the db to find the username $getuser = mysql_query("SELECT * FROM `users` WHERE `username` = '$username'"); //checks see if the username exists in the db $usernum = mysql_num_rows($getuser); //if it don't exist if($usernum == 0) { //don't exist echo ("User Not Found"); } //if it does exist then show there profile else{ $user = mysql_fetch_array($getuser); //to display image from source $dir = "prof_pics"; $sql = "SELECT prof_pic FROM users WHERE username = '$username'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0) die("Username not found in database."); $row = mysql_fetch_array($res); $pic="$dir/".$row['prof_pic']; $img="<img src=\"$pic\" width=\"88\" height=\"88\" align=\"center\"><br>"; echo " <b>$user[username]'s Profile</b><br><br> $img <br> Email: $user[email]<br> <a href='friendrequest.php?user=$user[username]'>Add as Friend</a> "; } }else{ //gets all the members from the database $getusers = mysql_query("SELECT * FROM `users` ORDER BY `uid` ASC") or die(mysql_error()); //loops there name out while ( $user = mysql_fetch_array($getusers)) { echo "<div id='memcontainer'> <div id='mempic'>$img</div> <div id='memname'><a href='members.php?user=$user[username]'>$user[username]</a></div></div><br> "; } } echo "<center>"; ?>
-
getting the number in "blah blah REFERENCE ID: [526] blah blah"
AyKay47 replied to ultrus's topic in Regex Help
no problem man.. please mark as solved.. -
you could redirect them yes, why wouldn't it work for you here? you would only need to change one line.. session_start(); if(isset($_SESSION['test'])){ if($_SESSION['test'] == 1){ header("Location: index.php"); } } now when you refresh the page it should redirect you to the index page
-
without knowing your table setup its hard to say, you could probably grab all the rows and order them by the sum of the points that they have, then print what number row that they are
-
nooo, basically what we are doing here is...the first time that a user clicks the link, there will not be a session that is set, so the code runs as normal...then at the end of execution we set a session to 1.. then the next time that the user would try to click on the page, they would get the error since the session is set
-
getting the number in "blah blah REFERENCE ID: [526] blah blah"
AyKay47 replied to ultrus's topic in Regex Help
$subject = "blah blah REFERENCE ID: [526] blah blah"; $pattern = '~^.*\[(\d+)\].*$~is'; preg_match($pattern, $subject, $matches); print $matches[0]; // print 526 -
why are you unsetting the session value, that the opposite of what you would want to do.. at the bottom belongs.. $_SESSION['view'] = 1;
-
yes, but I would do that before the condition anyway. $username = $_GET['user']; if(isset($username)) { this way you won't have to redefine
-
okay lets say that after all of the code that you want to run, you set $_SESSION['test'] = 1; at the very top of your code you would have something like session_start(); if(isset($_SESSION['test'])){ if($_SESSION['test'] == 1){ exit("Host already registered!"); } } remember at the very bottom of your page, after all of your initial code has been run is where you will want to place $_SESSION['test'] = 1;
-
is reg.php the target page that the array is sent to? Still not sure what you are trying to do, or how a form would have any relevance here.. but what you can do is display a form for each value in the array like so.. foreach($array as $value){ print "<form action='#' method='POST'> $value Active = <input type='radio' name='active' value='Yes' /><input type='radio' name='active' value='No' /><br /> Lease for Another 90 Days? <input type='radio' name='lease' value='Yes' /><input type='radio' name='lease' value='No' /><br /> Description <textarea name='description' cols='5' rows='30'></textarea> <input type='submit' name='$value' value='Submit' />"; } something like that perhaps, then you can grab the data based on which Host it is if(isset($_POST['Host1'])){ //if the submit button for Host1 has been pressed // sanitize data, insert into database }elseif(isset($_POST['Host2'])){ // is the submit button for Host2 has been pressed, etc... }
-
?? OP, as for the register once is concerned..there are quite a few ways that this can be done, once a user clicks on the link that they are given in the email, you can set a $_SESSION value to "read" or "1" or whatever value you want. If the session isn't set yet, proceed with the execution that you want to do, if the session is set, stop execution and show the user a message that the link has already been visited..perhaps something like that will do for you