Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1819 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Replace ); with a string

Thread title: Replace ); with a string
Closed Thread  
Page 1 of 2 1 2 >
    Thread tools Search this thread Display Modes  
07-08-2007, 09:06 PM
#1
Seraskier is offline Seraskier
Status: I love this place
Join date: Jan 2007
Location: Charlotte
Expertise:
Software:
 
Posts: 542
iTrader: 0 / 0%
 

Seraskier is an unknown quantity at this point

Send a message via AIM to Seraskier Send a message via MSN to Seraskier

  Old  Replace ); with a string

I am trying to use str_replace to replace ); with a string value.

users.php
PHP Code:
<?php
$users 
= array 

"100000" => array ( "username" => "Seraskier" ),
);
register.php
PHP Code:
<?php include("users.php");
$fopen fopen("users.php""a+");

if ( 
$_GET['action'] == "register" )
{
    
$id end(array_keys($users)) + 1;
    
$content str_replace(");"$id$users);
    
fwrite($fopen$content."\n);");
}

echo 
"<form method='post' action='?action=register'><input type='submit' value='Register'></form>";
?>
basically add a user into the array...

to replace ); with the array of the user, then have the code put in a ); after its inserted...except its not working..

07-08-2007, 09:23 PM
#2
Garrett is offline Garrett
Status: Waving
Join date: Aug 2005
Location:
Expertise:
Software:
 
Posts: 2,694
iTrader: 11 / 100%
 

Garrett is on a distinguished road

Send a message via MSN to Garrett

  Old

I am certain there is a function for PHP that inserts data into arrays, not sure if it's those types of arrays, but just in general.

07-08-2007, 09:32 PM
#3
Seraskier is offline Seraskier
Status: I love this place
Join date: Jan 2007
Location: Charlotte
Expertise:
Software:
 
Posts: 542
iTrader: 0 / 0%
 

Seraskier is an unknown quantity at this point

Send a message via AIM to Seraskier Send a message via MSN to Seraskier

  Old

yeah there is... but thats like temporary, im using this as a database...

07-09-2007, 02:14 AM
#4
Seraskier is offline Seraskier
Status: I love this place
Join date: Jan 2007
Location: Charlotte
Expertise:
Software:
 
Posts: 542
iTrader: 0 / 0%
 

Seraskier is an unknown quantity at this point

Send a message via AIM to Seraskier Send a message via MSN to Seraskier

  Old

I have looked at fget, fread, and acouple more. I know it is possible but if someone could post up anything that would help, that would be great.

Thank You.
Jordan Martin
Seraskier

07-09-2007, 02:18 AM
#5
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old

As both methods are incredibly bad, your better using a text file as your database in the following format

----
Username
----
Username2


MD5 it if you dont want unauthorized access. Just explode ---- and you have yourself the array.


Why arent you using a mysql database? Or XML if you dont have a mysql database?

07-09-2007, 06:05 AM
#6
Seraskier is offline Seraskier
Status: I love this place
Join date: Jan 2007
Location: Charlotte
Expertise:
Software:
 
Posts: 542
iTrader: 0 / 0%
 

Seraskier is an unknown quantity at this point

Send a message via AIM to Seraskier Send a message via MSN to Seraskier

  Old


As both methods are incredibly bad, your better using a text file as your database in the following format
id rather do it this way, I know that it is possible im just having trouble doing it.


MD5 it if you dont want unauthorized access. Just explode ---- and you have yourself the array.
I am going to password the file so it is unreadable to other people, depending on how i code it.


Why arent you using a mysql database? Or XML if you dont have a mysql database?
just trying something new

but if anybody can somehow help me out that would be great.

07-09-2007, 09:03 AM
#7
CreativeLogic is offline CreativeLogic
CreativeLogic's Avatar
Status: Request a custom title
Join date: Feb 2005
Location:
Expertise:
Software:
 
Posts: 1,078
iTrader: 6 / 100%
 

CreativeLogic is on a distinguished road

Send a message via MSN to CreativeLogic

  Old

What exactly is not working for you? You also need to close your file handle otherwise you're creating a memory leak.

I'm not so sure that you can include a file then attempt to write it in the same file. You can just read the users.php file into a variable then use www.php.net/eval to get the users variable.

For more help I'll need to know what exactly is not working for you.

07-09-2007, 03:01 PM
#8
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old

Originally Posted by Seraskier View Post
just trying something new
If you are going to try something new, I suggest it be a good, let alone useful thing.

07-09-2007, 06:29 PM
#9
Seraskier is offline Seraskier
Status: I love this place
Join date: Jan 2007
Location: Charlotte
Expertise:
Software:
 
Posts: 542
iTrader: 0 / 0%
 

Seraskier is an unknown quantity at this point

Send a message via AIM to Seraskier Send a message via MSN to Seraskier

  Old

Originally Posted by CreativeLogic View Post
For more help I'll need to know what exactly is not working for you.
Putting another array before );
PHP Code:
<?php
$users 
= array
(
"100000" => array ( "username" => "Seraskier" ),
);
?>
basically, putting a new entry into the array before the );

07-09-2007, 06:36 PM
#10
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

If you're looking for something simple, why not just save a serialized version of the array into the 'database' file (users.php). To use that, you'd just have to unserialize it and assign that value to a variable.

That makes more sense than playing around with file pointers and such like, to me at least. If you don't understand what I'm talking about, just ask.

Closed Thread  
Page 1 of 2 1 2 >


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed