
chocopi
Members-
Posts
551 -
Joined
-
Last visited
Never
Everything posted by chocopi
-
[SOLVED] Warning: mysql_close(): supplied argument......
chocopi replied to plutomed's topic in PHP Coding Help
is it because you have $con in a different function and it isnt carried over to the other function unless you set it to a gobal. this is just a guess seeing as I don't like functions so I don't use them ~ Chocopi -
check out these links on Google EDIT: I havent checked them out myself but they must have something useful.
-
Cheers Barand that works perfectly, I was thinking it was going to be more complex. I guess thats Topic Solved then Many thanks, ~ Chocopi
-
Thanks hitman6003 for the linky, it seems like it could be very helpful. @Barand: How would I go about re-writing the file or do you mean i should just use explode to single out the line and just piece it back together and write over the whole file? Many Thanks, ~ Chocopi
-
I have recently started to code a Flat file database (just for fun) and it's going fine, but I was wondering whats the best way to delete a line from the file. I have this code below and I would like to add a delete button besides each line, which would obviously delete that line. But I do not know the best way to go around doing this as I don't know any specific functions to use. <?php $filename = "db.txt"; $lines = file($filename); foreach($lines as $line) { list($id,$username,$password) = explode(",", $line); if($id != 0) { $username = ucwords($username); echo "{$id} {$username} {$password}<br />"; } } ?> So is there a simple function I can use I will I have to use multiple ones And help/advice/guidance would be greatly appreciated, Many thanks, ~ Chocopi
-
maybe its the lack of semi-colons
-
well assuming you already have the form and email setup all you need is the link. What I would do: 1. In your database store a unique string for the user (I usually md5 their username) at the registration and have a field called active which is set to 0 as default. 2. In your email have the message and on the link have http://www.yourpage.com/activation.php?id={$unique_string} 3. Then on activation.php all you need is to use GET to get the unique string where you look it up in the database for the user. 4. If found set active to 1. 5. For your login when checking if username and password match check they are active = 1. Well thats the basic idea. Hope it helps ~ Chocopi
-
The problem is still persisting even after removing sessions_start(); at the top of sessions.php The strange thing with this is that it still die()'s on line 35: $row = mysql_fetch_assoc($query) or die(mysql_error()); Yet nothing is being echoed. Now, I know its not a mysql error seeing as nothing is echoed. Then i turned on the error reporting and for a brief time and got this message to appear: Notice: Undefined index: user_familiar_name in /directory/folder/sessions.php on line 35 However, this message isn't showing up anymore yet i have changed squat, but im quite sure its still the same problem. So does anyone know what the above error means, and know how to rectify the problem. By the by the code giving me the problem is: <?php if(empty($user_familiar_name)) { $query = mysql_query("SELECT `name` FROM `kol_familiars` WHERE `id`='$user_familiar'") or die(mysql_error()); $row = mysql_fetch_assoc($query) or die(mysql_error()); $_SESSION['user_familiar_name'] = $row['name']; $user_familiar_name = ucwords($_SESSION['user_familiar_name']); } ?> Many thanks ~ Chocopi
-
it is, i have it on one page and then on anohter page which is required <?php session_start(); require('sessions.php'); ?> // sessions.php <?php session_start(); ?>
-
I would recommend usin databases as the require less code and are much easier! Text files are good if you don't have access to a database
-
cheers, but that just gets rid of the error message, which is quite random seeing as it still stops/dies in the same place The only error I get now is that i am using another session_start(); Thanks
-
Need Help!!!!!!!!! Images wont appear on my Website
chocopi replied to Xtrememods's topic in PHP Coding Help
Yea i can see the images and everything. FYI im using FireFox 2.0.0.6 -
Here we go I got the error message back: Notice: Undefined index: user_familiar_name in /data/members/free/tripod/uk/c/h/o/chocopi/htdocs/kol/sessions.php on line 35 Line 35: $user_familiar_name = $_SESSION['user_familiar_name']; So how do I go about fixing this, as I don't quite understand what it means Many thanks, ~ Chocopi
-
PHP Statment and Querys - Possible To Sum Up?
chocopi replied to tsilenzio's topic in PHP Coding Help
EDIT: Looks like I was beaten to it, twice seeing as i missed the second page. My bad -
Thanks, it thought error reporting was turned on but apparently not so im using: error_reporting(E_ALL); It said something to do with line 35 which is: $user_familiar_name = $_SESSION['user_familiar_name']; But for some reason the error message is not showing up now, even though the problem persists seeing as I havent changed anything. $user_familiar is set further up and that works fine. $user_familiar is a number which corresponds to the id's in the table hence why I am trying to take the name where the id from the user matches the table. The empty() part is working fine as I added echos onto every line to check where it stops, and it stops at $row. At first I thought it was a problem with using mysql_fetch_assoc but quite sure it isn't seeing as it is not throwing up anything from mysql_error(). So thanks for all of your help, but so far I think that premiso is the closest as the error message said something about user_familiar_name not being set/called/used or something along those lines. Many thanks, ~ Chocopi
-
For some reason, which I can't seem to work out, my script is dying. My code is: <?php if(empty($user_familiar_name)) { $query = mysql_query("SELECT `name` FROM `kol_familiars` WHERE `id`='$user_familiar'") or die(mysql_error()); $row = mysql_fetch_assoc($query) or die(mysql_error()); $_SESSION['user_familiar_name'] = $row['name']; $user_familiar_name = ucwords($_SESSION['user_familiar_name']); } ?> The script wil die on $row yet it does not give an error even though I have mysql_error(). So this means it isn't a mysql error, so i'm stumped I've tried using array and row instead of assoc but it still doesn't work. So I was wondering if anyone could shed some light on the matter. If you need any more info, drop me a line. Many thanks, ~ Chocopi
-
Cheers GingerRobot That works a treat, I knew it was easy And thanks DeepakJ for your help ~ Chocopi
-
Cheers, but can you please show me how to use it with my code, seeing as I have never got around to learning foreach. I sound like such a n00b. I really should know this, how embarassing Thanks, ~ chocopi
-
How do you go about adding all the values from a while loop. Here is my code: <?php $query = mysql_query("SELECT * FROM `Enemies` WHERE location='$location'") or die(mysql_error()); $num_row = mysql_num_rows($query) or die(mysql_error()); while($row = mysql_fetch_assoc($query)) { $rarity = $row['rarity']; $value = $rarity/100; $value2 = $value*$num_row; } ?> So this code would loop through 3 times for example and I would like to add up all of the $value2's. Now I know there is a way to do this, but I can't remember I think its along the line of $value2[0]+$value2[1]+$value2[2] or something like that, but as I said I can't remember. If you can help it would be much appreciated, Many Thanks, ~ Chocopi
-
[SOLVED] Checking if an image exists using fsock?
chocopi replied to RickyF's topic in PHP Coding Help
why dont you just use file_exists() ??? <?php $filename = '/path/to/foo.txt'; if (file_exists($filename)) { echo "The file $filename exists"; } else { echo "The file $filename does not exist"; } ?> or i think this might work (this is untested): <?php $fp = fsockopen("www.example.com"); if (!$fp) { echo "File does not exist<br />\n"; } else { echo "File exist<br />\n"; fclose($fp); } ?> Those are both off of php.net ~ Chocopi -
missing ; $add_topic_res = mysqli_query($mysqli, $add_topic_sql) should be $add_topic_res = mysqli_query($mysqli, $add_topic_sql); ~ Chocopi
-
you forgot the ; on $p_date = $date so it should be $p_date = $date; ~ Chocopi
-
A good example is if you are saving files and want to replace any of the spaces with underscores <?php $str = "hello world.gif"; $new_str = str_replace(" ","_",$str); echo $str; // should give hello world.gif echo $new_str; // should give hello_world.gif ?>
-
Need help for creating URL using PHP Reg Exp
chocopi replied to kks_krishna's topic in PHP Coding Help
I dont quite understand. Do you want an error if anything but alpha-numeric and - come up OR Do you want it just to remove them so HE-LLO$^ M"Y n@A~me IS C-h(oc*o&pi would become HE-LLO MY nAme IS C-hocopi ~ Chocopi -
kool, well im glad you got it fixed. I think if (eregi("^[[:digit:]]$", $newsid )) wasnt working when you got over 9 because you are missing a '+' sign befiore the '$'. I don't know much about regex but I think using '+$' instead of just '$' means that you can have nth length instead of just the one. So if you used: if (eregi("^[[:digit:]]+$", $newsid )) It should act in the same way as if (eregi("^([0-9])+$",$newsid)) And what I was saying about eregi is that the 'i' means it is case-insensitive wheres using ereg would do the same thing as you are using numbers, and numbers cant be capitals or lowercase Well I hope that clears up everything, Happy Codding ~ Chocopi