premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
$result = mysql_query($frasesql, $link) or die(mysql_error()); It will if you add that line I bet.
-
I take it you did not make this script, but either paid someone or inherited it. Is this a new issue? When did it start happening, what did you change on the server? That is a lot of code to go through without being able to test it to know what is happening. Let us know the answer to those questions, thanks.
-
How long should the average PHP script take to run?
premiso replied to futurshox's topic in PHP Coding Help
On average, with a database, usually about 0.xxxx seconds somewhere around there. But it really depends on the processes You can look at the bottom of this site and see an average time: "Page created in 0.113 seconds with 17 queries." But you said it could haev 60+ inputs to do, that is 60 queries. So you could times that by 60 and get an average time your script will take to run. But with databases it never is that simple, it will probably take about 5-10 seconds+ to run 60 queries on 1 page. If you can consolidate the queries that would speed up the processing time. -
Your not doing a mysql_select_db in that code after the connect....
-
If you want the list but do not want the notices, this would solve that problem. for($n=0;$n<count($lines);$n=10){ if (stristr($lines[$n], ':') !== false) { $res=list($a,$b)=explode(':',$lines[$n]); echo '<pre>'; print_r($res); echo '</pre>'; } $n++; if (stristr($lines[$n], ':') !== false) { $res1=list($c,$d)=explode(':',$lines[$n]); echo '<pre>'; print_r($res1); echo '</pre>'; } }
-
how to add a method to an existing object?
premiso replied to simplemedia's topic in PHP Coding Help
It has to be defined inside the class before the script is ran. Once it is ran, that is the object and the definition cannot be changed on the fly. -
Yea extract works, but still gives the same flaw with any post variables. But it is more secure than having the cookies/session/post/get all being made into their variables. You could even use a loop in place of extract with an array of defined variables coming from the form, but yea. Another option I guess.
-
<?php $action = isset($_GET['content'])?$_GET['content']:'home'; switch($action) { default: case 'home': echo 'You are home!'; break; case 'shoutbox': // code for the shoutbox break; case 'aboutus': // code for about us break; } ?> Makes it a bit nicer so you do not have to always do the conditionals/brackets, but yea just about as much work.
-
The quick fix, which I highly do not recommend due to security issues is you can turn register_globals on in the php.ini. But yea it is better to define them at the top of the page so you know what is coming in. IE for each variable that is retrieved from post you can just put this code at the top of the page: $pageTitle = isset($_POST['pageTitle'])?$_POST['pageTitle']:null; $pageDescription = isset($_POST['pageDescription'])?$_POST['pageDescription']:null; And that is much better alternative than turning back on register_globals.
-
If each condition has it's own deal, sadly no. You would need an if statement or a Switch/Case statement. The switch might be better suited for this. Either way the, logic has to stay in there. If the code does get put into MySQL (which there is no reason to do it cause you would have the same amount of code, just more strain on your db) you would have to use eval to run that code out of the db.
-
I am pretty sure it is because GMail does the character encoding on it's end. See what your character encoding is set to on FireBird, it is probably UTF-8, which would explain it. Try changing that to the ISO and see what happens.
-
Umm add a check using stristr ? <?php // messages.php if (isset($_POST['message'])) { if (file_exists('messageCount.txt')) { $count = fopen('messageCount.txt','r+'); $n = fread($count,1024); } else { $count = fopen('messageCount.txt','a+'); $n = 0; } if (($e = ($n + 1)) <= 10) { rewind($count); fwrite($count,$e); fclose($count); $fp = fopen('messages.txt', 'a'); if (stristr($n, $_POST['message']) === false) fwrite($fp, "{$_POST['message']}<br />"); fclose($fp); } } readfile('messages.txt'); ?> I think that is what you are looking for....
-
This is probably better for the initial step. That way you have all the currentids in the updates column then you can manipulate the tool_id without worrying about if it copied right =)
-
You can do it with session, but you still have to "re-create" it in a sense. I cannot remember excatly how it is done, but I think it is something similiar to this: <?php session_start(); include('classdefinition.php'); // this is required. if (!isset($_SESSION['object'])) { $object = new class(); }else { $object = unserialize($_SESSION['object']); } // this needs to be at the end of the processing. $_SESSION['object'] = serialize($object); ?> I am not 100% sure if that is the correct code. I think I am missing something, but that is the basic gist of it. If I do some research and find out if that is right I will let you know. EDIT: Alright I remembered what I was missing, the serialize and unserialize functions. The above should work now.
-
<?php switch ($i) { case 1: echo '<img src="image1.png" />'; break; case 2: echo '<img src="image2.png" />'; break; } ?> There is the basis of the logic.
-
Not hard at all really. As long as you have the new tool_id handy... First I would manually alter the table and add updatestool_id via phpMyAdmin or another means. Then you can run this code on php (note I do not know how you are getting the new id, so yea this is loosely based: mysql_query("UPDATE tools SET updatetool_id = `tool_id`, tool_id = " . $newToolId . " WHERE tool_id = " . $oldToolId); That should do the trick, I am not sure so I would try this on a test DB before testing it on the production database.
-
[SOLVED] Will Having alot of Session Variables Slow Down Your Website?
premiso replied to limitphp's topic in PHP Coding Help
thanks guys.... Actually, crayon, I was just reading your pagination tutorial...and I was thinking, if I store the page number in a session variable, can I assume its alot more secure, and not have to do all the isnumeric checking and greater than totalpages checking? But if you want it to be viewable to indexing bots, it needs to be apart of the url or else they will never be able to goto the next page. -
Solving. I think I found a solution that will work for me: http://www.walterzorn.com/dragdrop/dragdrop_e.htm Let the user be able to drag and drop on their site, then have an area where they can change the colors and fonts etc of each div. This should work out pretty good. Will be doing some testing on how to actually get it functioning. Thanks for the feedback!
-
That is really not a bad idea. The only issue I would have with that is CSS is a pain to get working cross-browser. But then again I may not care. Thanks for the idea, I really like that one and am going to look into that.
-
Extract data from $row into database. Simple thing i think...
premiso replied to cs.punk's topic in PHP Coding Help
Huh. Never knew about that shortcut, I always assigned them to new vars just to be safe. Yea I did not point that his code is very prone to SQL Injection without escaping $_POST. -
More like: <?php session_start(); if (isset($_SESSION['submit_score'])) die("You have already submitted."); $_SESSION['submit_score'] = $_POST['submit_score']; ?> That would work, but you may want to put the actual setting of the session in a spot past any probably errors that may occur...
-
Either way your users are going to need to learn some new syntax besides that of just plain html. Minimal amounts of php within your view layer is easy (when programmed properly) to learn and will always execute much faster than any template layer you add to the equation. Maybe I will toss that idea around. I do not wonder if I could just have them use html like syntax....and parse out those bits. I will do some google research and try that route. Thanks for the reply thorpe.
-
Why not set session data....if the score has been submitted set a session string then check that on page load.
-
<?php echo "<li class=\"med\">".date('d/m/Y',strtotime($departureDate))."</li>"; ?> You forgot the initial ? between < and php =)
-
What do you think they store the music clips as? mp3 or something similar, or it doesn't matter? thanks for the info! I want to use what they use....because their songs load so much quicker than other websites....its almost like itunes...where the song plays almost instantly.... Whatever can be played via flash, mp3, wmv, as. As long as the server has the codecs and the medium to play them it does not matter.