-
Posts
1,216 -
Joined
-
Last visited
Everything posted by WebStyles
-
Setting # of items per row from database...
WebStyles replied to jch02140's topic in PHP Coding Help
also, if you're basing it on the values of $i, where does $i start, and where is it incremented? -
if you could post your code, maybe someone can help. thanks.
-
Writing to an exact Ln, Col of a file
WebStyles replied to Freedom-n-Democrazy's topic in PHP Coding Help
Possible? yes. You'll probably have to read the entire text file into a variable, split it into lines, find the line you want, split it into columns, write your changes, then save the whole thing back into the text file. As long as you know how the text file is structured, it should be quite easy. (although not very practical, and error prone) -
ok, so you basically want to create a new file and put a line like this: "Test Case 1, <a href='link.to.test.com'>How to test</a>" inside the created file for each selected case... Can you post the exact code where your forms are? (one of the files in ./shc/)
-
since all the selectable options are checkboxes, and unchecked boxes DO NOT get sent in a form, checking for the existence of each one is redundant. But I'm not sure I get exactly what your objective is. You want to grab all selected checkbox names, and store them in a file?
-
this: include './sch/$etad.htm'; will not work, because php will not interpret variables inside single quotes. You can either do this: include './sch/'.$etad.'.htm'; or use double quotes: include "./sch/$etad.htm";
-
you can simply put in a condition: if($filename != '.' && $filename != '..'){ // ... show stuff }
-
you could create a function (so you can re-use it later on other situations) function cutTitle($string) { if (strlen($string) > { preg_match('/(.{' . 8 . '}.*?)\b/', $string, $matches); return rtrim($matches[1]) . '...'; } else { return $str; } } then, instead of print "<br />".$line["title"]."<br />".$line["views"]." views"; try something like print "<br />".cutTitle($line['title'])."<br />".$line["views"]." views";
-
chr() concerning an ereg_replace() use of function enquiry
WebStyles replied to j.smith1981's topic in PHP Coding Help
chr expects an ascii code as a parameter, and it will return the corresponding character... in this case, chr(0) is the NULL character... just chr() with nothing inside will most probably throw a warning. -
try this: <?php $jsonurl = 'http://api.twitter.com/1/trends/44418.json'; $json = file_get_contents($jsonurl,0,null,null); $json_output = json_decode($json,true); $trends = $json_output[0]['trends']; foreach ( $trends as $trend ){ echo $trend['name']."<br />"; } ?> *whenever you're in doubt with arrays, it's best to use: echo '<pre>'; print_r($array); to look at the whole structure of the returned/converted array. EDIT: Sorry, forgot the creation date/time, it will be in: echo $json_output[0]['as_of'];
-
You should define what your character limit is first, so you know if the title needs chopping or not, something like if(strlen($title) > { //... rest of code } or else, that code will also convert a shorter title like 'PHP freaks' into 'PHP' unnecessarily.
-
thanks Maq. Cool reading. Setup and usage is quite straight-forward... I'm currently at 40% of a large intranet system I'm building, and was considering a conversion to mongoDB before launching... This would not be too hard to code in because I have all the function files separate, so every select, update or insert can easily be found and converted to something else... No mention on replication/backups though, which worries me... I was considering a dual system. Option 1 would be to use mongoDB but replicate all data to a mysql server, just in case I change my mind and want to quickly convert back without the hassle of migrating databases... Option 2 would be to leave everything as is, continue development, but on every insert, also insert into a mongoDB system so I can play around with it on the side until I'm comfortable. I wonder if I can set up mysql triggers to update a mongoDB database... hmmm... The only drawback is my time frame for completing the job, otherwise I would be the first to start experimenting. Some features seem a bit "extreme" to me (although certainly useful in some situations), like if the database does not exist, it gets created on the fly... Could be very useful, but a simple typo would leave me with a useless new database... Will need to investigate more. thanks for the link.
-
Just curious if anyone is using mongoDB, and how does it compare to mysql in terms of stuff we're so used to using, like mysql_real_escape_string, mysql_fetch_assoc, mysql_affected_rows, mysql_insert_id, mysql_num_rows, etc... Everyone boasts it's much faster (100 x they say), I'm just wondering, before I dwell into reading manuals, setting up a test zone and trying things out, if it's even worth considering for smaller scale projects like intranets for 200-300 people, (where every single click, update, change, etc.. is logged in one way or another, creating several selects and inserts per page, used intensively by 150 people 10 hours per day) Anyone out there with experience on mongoDB ? Troubles/benefits ? End result worth the hassle or only noticeable on huge systems ? Thanks
-
I always code from scratch.
-
you don't even want to try, you simply want us to do your work for you?
-
lots of things missing or don't make sense here I only read about 15 lines of your code and I have these questions: ... where's your question? why are you using that redundant if inside the switch statement? where does $action come from? where and how do you connect to mysql? why is your query based on a url variable that you don't check for existence first? why is the field id in lowercase when you create your query, but in uppercase when you try to retrieve it? why are you using <form action="switch.php?id=<?php echo $row['ID']?> if you already had the same id from $_GET['id'] even before your query? ... anyway, since the title was 'switch help', here's how a switch statement works: switch($_GET['action']){ case 'delete': // code to delete stuff break; case 'edit': // code to edit stuff break; case 'write': // code to write stuff break; }
-
I tried your code and it worked great.... hmmm.... Wait a minute... What code?
-
I'm not sure if this is what you mean, that explanation was more than confusing, but I'll give it a go: you want to pull out five records from your database and create a radio button for each??? $q = mysql_query("select `degreeID` from `table2` order by `degreeID` limit 5",$conn); while($r = mysql_fetch_assoc($q)){ echo '<input name="mom_ed" type="radio" value="'.$r['degreeID'].'"> '.$r['degreeID'].'<br />'; } ???
-
just call the checkboxes something like myBox[] (i.e. all with same name) and on the next page loop through that array to find out which ones were selected: foreach($_POST['myBox'] as $box){ echo $box.'<br />'; }
-
Putting it all together...displaying array!
WebStyles replied to usmarinenco's topic in PHP Coding Help
mysql_fetch_assoc($result) expects $result to contain a valid sql query. I'm guessing it does not. (didn't read your code, just checked line 51 based on the error you gave us) -
kind of off-topic, but how is $cachetime = 60 * 60 * 400; // 5 days equal to five days?
-
as far as I know, there's really no way to correctly detect if the user finished the download, unless you embed some kind of applet in the download, or use flash, or something like that... (PHP is server-side, and the download happens on the client-side... you would need the client to send you some info AFTER the download, which will probably not happen). You can however count the size of each file in bytes, and use http headers to try and detect how many bytes have been downloaded, but this will be complicated and not as accurate as you would wish. You could also "guess" if download was completed based on the time since they start the download, the file size, the connection speed (which you need to establish before the download) and the time of the user's next activity on the website after the download. Also not a brilliant solution.
-
either I'm not fully understanding the problem, or that is just strange... you have people inputting stuff into an access database that is then inserted into a mysql database, and then you want to display the information from the access file again? seems you're going down a road that will bring you many headaches in the future. Would be much better to forget about the access file and create a system in php/mysql where they can input the data needed (if they're used to / only understand access, there's nothing preventing you from designing the page to look like an access database)
-
have you simply checked your logs? chances are all errors are already being logged to file.
-
Did you try it? (seems redundant to me. Read through it again and you'll see what I mean) also, what do yo mean 'log any php errors' ? log them to a file, or show them on the page that contains the errors ?