Jump to content

thehigherentity

Members
  • Posts

    49
  • Joined

  • Last visited

    Never

Everything posted by thehigherentity

  1. [!--quoteo(post=383064:date=Jun 12 2006, 08:47 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 12 2006, 08:47 PM) [snapback]383064[/snapback][/div][div class=\'quotemain\'][!--quotec--] I don't really understand your problem. How did you create the table in the first place. How did you create and define the fields that make up each row? How could you not actually know the structure of a database you created? Doing a little reading will help you learn faster than just asking questions. At worst, you'll get the terminology right :) [/quote] the database I have created isnt a problem right now, even though... I will come back to them in a few month and wont have a clue what i called the fields with the tables. I have created a small database with only 3 fields at the moment and there id, user and comment all i am doing in playing arround with these making sure i know how to delete move and change the information befor i even attempt to make anything with the connection. I have a guest book installed on my server and i have been trying to access the information within there too and this is were i have had some problems, I know how to find the table names but im lost on how to find the field names and I have read a number of sites and looked through my referance books but non of these seem to consider the fact that you could be working on somthing that somone else has created. I would of thought there would be a simple command to do this, it seems very logical to me? anyway thanks for the links, I will go check them out now see if i can find anything there Just so you know i found what i wanted thanks for the help :) [code] mysql_field_name() [/code]
  2. I can view the data in a table if i know what the rows are called, eg im using this at the moment [code] $link = mysql_connect($host, $user, $pass); // conect to the mysql databases if (!mysql_select_db ($dbname)) die ("WE have a big problem, <br>I cant connect to the database $dbname"); // select the database to work with $query = "SELECT * from $tablename"; $result = mysql_db_query($dbname, $query, $link); // create a table print ("<TABLE BORDER=1 WIDTH=\"75%\" CELLSPACING=2 CELLPADDING=2 ALIGN=CENTER>\n"); print ("<TR ALIGN=CENTER VALIGN=TOP>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>I.D</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>Username</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>Comments</TD>\n"); print ("<TR>\n"); while($row = mysql_fetch_array($result)){     print("<TR ALIGN=CENTER VALIGN=TOP>\n");     print("<TD ALIGN=CENTER VALIGN=TOP>$row[id]</TD>\n");     print("<TD ALIGN=CENTER VALIGN=TOP>$row[user_name]</TD>\n");     print("<TD ALIGN=CENTER VALIGN=TOP>$row[information]</TD>\n");     print("</TR>"); } mysql_close($link); [/code] however, lets say i dont know the names of the rows "$row[user_name]" how can i find that out? and how can i find out how many of them there are? my problem is i like flat files becouse i can look inside and see for myself, but im working on somthing thats far too big for flat files so i realy need to learn mysql now, i have worked out its a lot easyer to work with then i thought but its just knowing how to do it in the first place thanks for any help you can give and i hope thats explained things a little better
  3. basicaly I have only just got my head round making and removing tables in mysql I have been using the following code to see if the tables were there or not, now im onto writing information into the table i dont seem to have any way of checking the info is actualy there. So my question is, can this code be changed to read the information within the tables too ? if so can somone point me in the right direction of how to go about this what i could realy do with is it showing the rows and the values or information within them so i can actualy tell i am doing things right this would be a great help to me if somone could help with this [code] $link = mysql_connect($host, $user, $pass); $result = mysql_list_dbs($link); $row_numb = mysql_num_rows($result); while ($db_data = mysql_fetch_row($result )){     echo $db_data[0]."<br>";     $result2 = mysql_list_tables($db_data[0]);     $num_rows2 = mysql_num_rows($result2);     while($table_data = mysql_fetch_row($result2)) {         echo "--".$table_data[0]."<br>";     }     echo "==> $num_rows2 table(s) in ".$db_data[0]."<p>"; } mysql_close($link); [/code]
  4. [!--quoteo(post=382793:date=Jun 12 2006, 06:03 AM:name=scripts2go.co.uk)--][div class=\'quotetop\']QUOTE(scripts2go.co.uk @ Jun 12 2006, 06:03 AM) [snapback]382793[/snapback][/div][div class=\'quotemain\'][!--quotec--] Guessing by the above you are using a hosting company as apposed to running your own local web server. If this is the case a lot of hosting companies (Including Mine) will allow you to create your own Databases but only through their admin interface. I have a test server which i use and the following code worked for me on that server but not on my ISP Server. [code] <?php $query = "CREATE DATABASE my_db"; $user = "username"; $pass = "password"; $host = "localhost"; mysql_connect($host, $user, $pass) or die(mysql_error()); mysql_query($query) or die(mysql_error()); ?> [/code] [/quote] I think you could be right, I have created a db through the admin area and I have managed to create the tables etc with code so it seems its the server host company thats blocking my code from making the db. but never mind, now i just have to get my head round getting the data into the database lol Im sure i will be posting again soon! thanks for your help
  5. im trying to get better with mysql and at the moment im trying to create a new database with php code, however it just wont work i have looked all over and read just about everything i can find about creating a db according to the admin section of my server i Im using PHP version 5.0.5 and MySQL version 4.1.19 and i have the rights to create and drop databases as well as change the tables etc I first tried myaql_create_db befor i found out this will not work I believe the right code is ment to be mysql_query("CREATE DATABASE my_db") however this wont work eather, all i get is an error saying somthing like Access denied for user 'username'@'localhost' to database 'my_db' but i can connect and read the other already existing databases? is there somthing im missing here i was under the impresion mysql was easy to connect to is there anyway i can test my privaliges and see if its somthing like that? or any other ideas would be great
  6. Im not on the right computer at the moment so I cant post the code but… I can tell you it’s a standard text area, which I am collecting the information through extract($_POST); // I will be changing that when I have it working properly all I have is echo $text; and on the html it looks fine but when I look at the code there is extra spaces.(well there is when I add then to the text area). The text is displayed back into the text area with a simple echo and the spaces are in the text box too; This is why I striped the code down to its bones and I still find the spaces are there I need to compare some of the input to existing information in my database so I need to remove these spaces. If I echo the information to screen it only shows the one space but like I say in the actual source code there are more [!--quoteo(post=380867:date=Jun 7 2006, 12:08 AM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 7 2006, 12:08 AM) [snapback]380867[/snapback][/div][div class=\'quotemain\'][!--quotec--] Crayon, they are not removed. They are merely not displayed by the browser, but if you put <pre> tags you will see them. You might want to use [code]$newstring = preg_replace("/ {2,}/", " ", $oldstring);[/code] [/quote] Thanks for that I will give it a go later today!
  7. I know this is probably really easy but I can’t seem to get my head round “preg_replace” Im trying to remove excessive spaces, so if someone’s input has more then one space anywhere in the text (not just at the beginning or the end ) it will remove the extras and leave only one. I know trim () will do the leading and end ones but I need it so any more then one space, anywhere in the text is not allowed! And will be changed back to one single space [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /] If someone could help me with this I would be very grateful
  8. I have spaces showing up under my submit buttons how can i fix this?
  9. [!--quoteo(post=377846:date=May 28 2006, 10:11 AM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ May 28 2006, 10:11 AM) [snapback]377846[/snapback][/div][div class=\'quotemain\'][!--quotec--] Upload the image and re-size it so its dimensions suit your requirements, then save the image and image data. [/quote] Just wondering, but how do you change the size of an image once it has been uploaded?
  10. I Thought I would let you all know how i fixed this problem, I made two functions one to extract the data. [code] function extract_from_tags($str, $open_tag, $close_tag){     $findopenings = explode($open_tag, $str);     foreach($findopenings as $find_closings){         $taginfo = explode($close_tag, $find_closings);         if (trim($taginfo[1]) == ""){             $after_tag[] = $taginfo[0];             $tag_info[] = " ";         } else {             $tag_info[] = $taginfo[0];             $after_tag[] = $taginfo[1];                 }     }     $str = array($tag_info, $after_tag);     return $str; } [/code] and one to place it back again [code] function replace_to_tags($tag_info, $outer_tag, $open_tag, $close_tag){     $str = "";     $info_count = count($tag_info);     for ($i=0; $i<$info_count; $i++){         if ($i == 0){             if (trim($tag_info[$i]) == ""){                 $tag_first = false;             } else {                 $tag_first = true;             }         }         if ($tag_first = true){             if (trim($tag_info[$i]) == ""){                 $str .= $tag_info[$i].$outer_tag[$i];             } else {                 $str .= $open_tag.$tag_info[$i].$close_tag.$outer_tag[$i];                         }         } else {             if (trim($tag_info[$i]) == ""){                 $str .= $outer_tag[$i].$tag_info[$i];             } else {                 $str .= $outer_tag[$i].$open_tag.$tag_info[$i].$close_tag;                         }                 }     }     return $str; } [/code] I know its far from perfect code but it seems to work but here is how it works [code] $str = "[MYTAG]INFO NEEDED 1[/mytag]between 1 and 2[mytag]info from tag 2[/MYTAG]BETWEEN 2 AND £[mytag]info from tag 3[/mytag]from the end"; $open_tag = "["; //  opening tag $close_tag = "]"; // closing tag [/code] then call the function with [code] $str = extract_from_tags($str, $open_tag, $close_tag); [/code] this gives you a multidimensional array all the info between the tags would be on $str[0] and the rest would be on $str[1] so you could call it like $str[1][1] or $str[1][2] etc this means I can edit them and then place them back into the array and run the following [code] $tag_info = $str[0]; $outer_tag = $str[1]; Str = replace_to_tags($tag_info, $outer_tag, $open_tag, $close_tag); [/code] To get my desired output I hope this helps anyone else that has a similar problem It seems to of solved all my problems so far making it easy to extract what ever I want and place it back were it was before Critics welcome, after all I’m only learning and as I said I know its far from perfect
  11. I never new you could do this [code] <?php $wanted_info[] = $filedata[$col]; ?>[/code] anyway it works, thanks :)
  12. I am useing a foreach loop to collect information for a file the info is stored as blah blah blah |~|blah blah blah |~|blah blah blah |~|blah blah blah |~|blah blah blah within my loop i have the following $store .= $filedata[$col]."|~|"; this collects differt info depending on the line. but my problem is when I tryed to implode the $tore it would not work? this is the code i used to implode $wanted_info = implode("|~|", $store); and this is the error i get Warning: implode(): Bad arguments I know the info is in $store as i can echo this out and its all fine?
  13. thanks for your quick reply on this I never thought of that I do have one question though If i wanted to have many different tags and be able to extract them in this way is there any way I can go throught a string and lowercase anything between [ and ] ? this would then fix all my problems :)
  14. OK, im lost again I want to pill out a section of a string from between two different tags I want to make a couple of functions. I need them to work by inputting the opening and closing tags eg [mytag] and [/mytag] with the str So the first function would do something like Lets say “exreact_info” is the name of my function [code] $open_tag = “[mytag]”; $close_tag =”[/mytag]”; $str = “blah blah blah [mytag] info needed 1 [/mytag]blah blah blah[mytag]info needed 2[/mytag]blah blah blah[mytag]info needed 3[/mytag] blah blah blah”; $tagarray = exreact_info($str , $open_tag , $close_tag); [/code] I hope that this could then give me something like [code] $tagarray[0] // info needed 1 $tagarray[1] // info needed 2 $tagarray[2] // info needed 3 [/code] Then i need a function to put the info back into one string again as it was before but with the edited information, something like the following [code] $str = “blah blah blah [mytag] info needed 1 * edited [/mytag]blah blah blah[mytag]info needed 2 * edited [/mytag]blah blah blah[mytag]info needed 3 * edited [/mytag] blah blah blah”; [/code] Im not asking someone to make these functions for me, I wont mind if someone does but I would like to know how to go about it. I first tried with explode and managed to get it kind of working but then found it was case sensitive and I need this to work with all variations eg [MyTaG] to work just like [mytag] etc I hope this all makes sense I have been up all night trying to get this code Finished and I’m just about asleep now
  15. I am trying to make a form that allows BBCODE type input so far it works but there are a couple of problems i cant work out one is when a link is submitted starting with www. it is converted with the following code to a showable link but I dont know how to make it work with the http:// on the beggining [code]$url = preg_replace("/\[url=(\W?)(.*?)(\W?)\](.*?)\[\/url\]/i", '<a class="bbcode_links" href="http://$2">$4</a>', $url); // change bbcode links[/code] I know i could str_replace it out but I cant make it work on a mix of lower and upper case letters is there a way i can work it into the above preg_replace so it would remove the http:// at the same time as changing the code over to a html link? my other problem is white spaces [mytags] <<<< I have many of these tag names and need the code to work on them all so like the above code recognisses the [ ] to know its a tag, i need somthing like this for removing the white space I want a way to remove all spaces from between [ mytags ] << them tags so i would end up with [mytags] so even if the input was [ m y t a g s ] it would still come out as [mytags] it would also be great if i could remove new lines and breaks etc from inside them tags too. at the same time i need to fine a way of doing cind of the same thing with the text outside the tags but not all the spaces just the leading and ending space eg [mytags] blah blah blah [/mytags] would become [mytags]blah blah blah[/mytags] i dont want to remove new lines or anything with this part though please help it has taken me days to work out the rest and its realy not far from finnished now this is just about my last problem
  16. I actualy ended up using htmlspecialchars(); but i have a question Is str_replace() fast enough to do so many changes ? would there be a problem if i ran say 100 or so changes with str_replace()? i dont intend to do so but i am interested in knowing its limitations
  17. I want to make a function to replace all the specal text caricatures what is the best way to go about it? I thought about [code] $search // array of key symbols         $replace // array of replacments $newtext = preg_replace($search, $replace, $oldtext); [/code] only problem is when i started to look into this i found there is 100's of them just incase my post isnt clear i mean replacing things like the following ‘ with its code ’ with its code ‚ with its code etc etc etc
  18. I know there is a standard memory limmit of 8 in php and i know it can be changed in the ini file but is there a way to see how much memory a page is useing? I am loading up a lot of info from a text file and just to see how much i could load i loadedup the file with information until i got the memory error. but it would be nice to have some way of knowing how close you are to the limmit when making a site also if this is posible i would like to make somthing that stops it from readin the file befor it hits the limmit. has anyone every done this and how did they go about it? sorry some how posted this two time please feel free to remove one of them
  19. I know there is a standard memory limmit of 8 in php and i know it can be changed in the ini file but is there a way to see how much memory a page is useing? I am loading up a lot of info from a text file and just to see how much i could load i loadedup the file with information until i got the memory error. but it would be nice to have some way of knowing how close you are to the limmit when making a site also if this is posible i would like to make somthing that stops it from readin the file befor it hits the limmit. has anyone every done this and how did they go about it?
  20. just sorted it on another forum, if any one is interested it just needed an i after the search like the following [code] $text = preg_replace("/\[size=(\W?)(.*?)(\W?)\](.*?)\[\/size\]/i", '<span style="font-size:$2px">$4</span>', $text); // lowercase [/code]
  21. I'm having truble getting my head round the preg_replace, Im working on a bbcode function but cant work out if there is a way to turn the case sensative on and off, eg this is what i have at the mo [code] $text = preg_replace("/\[size=(\W?)(.*?)(\W?)\](.*?)\[\/size\]/", '<span style="font-size:$2px">$4</span>', $text); // lowercase $text = preg_replace("/\[SIZE=(\W?)(.*?)(\W?)\](.*?)\[\/SIZE\]/", '<span style="font-size:$2px">$4</span>', $text); // uppercase [/code] Is there a way to write this into one pass ? so SIZE= would be treated the same as size= ?
  22. Thanks m8, I tryed adding that into my ccs but it did not work so i messed arround and found that absolute worked fine so thanks i would not of worked it out with out knowing what css command placed images in that way thanks again thehigherentity
  23. I am trying to float an image on my site. I have a page full of text. I want to float images over the top so the text will run behind the images. I have seen this done befor so i know its posible some how. all i have setup is <img style="float:left" src="./images/image1.jpg" width="100" height="80" /> but as you will know this places the image into the text. could anyone help me with a way to place these images over the text? thanks, hope this makes sense TheHigherEntity
×
×
  • 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.