-
Posts
3,584 -
Joined
-
Last visited
-
Days Won
3
Everything posted by JonnoTheDev
-
Can you not select the fields you need and join the tables using your SQL
-
[SOLVED] Halting the PHP execution process
JonnoTheDev replied to Xu Wei Jie's topic in PHP Coding Help
Maybe set a flag in a text file. Each process caould read the file proir to execution. If the flag is set the process terminates or is not invoked. -
Ah. Here you go $n = 3; $x = str_pad(1, $n, 0); $y = str_pad(9, $n, 9); $array = range($x, $y); print "<pre>"; print_r($array); print "</pre>";
-
Need an interface to add/delete/modify products...
JonnoTheDev replied to Omzy's topic in PHP Coding Help
If its only your friend updating the website then why use a login system. Just put the admin files in a folder called admin/ and protect using htpasswd - easy. Image uploading and resizing isn't that hard. I use imagemagick but you could use GD functions. There are loads of examples. -
$n = 3; switch($n) { case 2: $array = range(10,99); break; case 3: $array = range(100,999); break; default: $array = array(); break; } print "<pre>".$array."</pre>";
-
Set as an array <select name="fqdn[]" multiple="multiple"> Then foreach($_POST['fqdn'] as $fqdn) { }
-
yes You access POST data using $_POST i.e. // check the id submitted if(is_numeric($_POST['id'])) { // replace x with your database value if($_POST['id'] == x) { } } <form method="post"> <input type="text" name="id" /> <input type="submit" value="submit" /> </form>
-
Communication between PHP scripts. How?
JonnoTheDev replied to username123's topic in PHP Coding Help
What is it exactly that you are updating? Why would you need to update 500000 rows? -
Because his use of the system() function. DjMikeS you are correct in an everyday approach to have a function that writes to a file, however not when the system output buffer is directly to a file system("php xxx.php > outputfile.txt",$retval) As Xu Wei Jie has stated the whole script needs to be processed prior to anything being written! Unless the approach to using the stderr works I see no alternative.
-
there is your problem. your value is not set in the session. check your code that sets this value.
-
How to detect if text file is uploaded ?
JonnoTheDev replied to markthien's topic in PHP Coding Help
How can a virus be in a text file? How would an attacker get it to run when it is you that decides where the file is uploaded to. If the text file is to contain certain data then you can read it to verify the contents. Simply checking the file extension will suffice (.txt) and that is as far as I would go. -
Do you see the correct query with the correct job id within the query when you print to the screen? print $query1;
-
Communication between PHP scripts. How?
JonnoTheDev replied to username123's topic in PHP Coding Help
No, your thought process is not on the lines of how PHP works. Scripts do not communicate with each other. Script 1 does a specific job Script 2 does a specific job and is independent of script 1. Like I said if script 1 is running in the background (i.e. run from the command line) then script 2 which is accessed from a web browser by a user request cannot read into script 1 and say where are you up to? Script 2 gets rows from the database to display to the user, correct? If you do not want to return rows that script 1 is updating then a simple flag on these records will act as the condition in the WHERE claus of the SQL that script 2 uses. -
This is bad syntax. You braces have no apparent function. $colcnt--;{ Also echo "$Java1"; Does not need to be contained with " echo $Java1 Check your code carefully. Is your query returning the correct results?
-
Does this print the query to the screen? You said you got a blank screen. print $query1; If you get nothing issuing this command then there must be a script error. If you do see the query then all is OK. I cannot see what you are expecting to be on the screen as your code is cut off.
-
Firstly you do not need to open and close php tags like you are. ?> <?php The fact that you are getting a blank screen suggests there is an error but you have error reporting disabled. You can change this in your php ini file or add the following to the top of your your script. I would suggest placing this in a common include (included on all pages of your site): ini_set('display_errors', 1); ini_set('error_reporting', E_ALL & ~E_NOTICE); Also the @ on your functions supresses errors. You should get rid of this. @mysql_select_db($dbname, $conn) mysql_select_db($dbname, $conn)
-
You will need to edit the select query and the hyperlink as I dont know you field names or filenames $query=mysql_query("SELECT id, names FROM employee WHERE status='Active'"); $names = array(); while($row = mysql_fetch_object($query)) { $names[] = "<a href='myfile.php?id=".$row->id."'>".$row->names."</a>"; } echo implode(", ", $names);
-
Communication between PHP scripts. How?
JonnoTheDev replied to username123's topic in PHP Coding Help
A session wouldn't work if the update is running from the command line. Sessions are created from the browser per user. As you say use a flag field in the table. Before it starts updating set the flag (i.e. recordLock) on all rows it is about to update: UPDATE table SET recordLock = '1' WHERE ..... Reset the flag when a record is updated or reset with 1 query at the end of the update UPDATE table SET recordLock = '0' WHERE recordLock='1' The other script cannot view rows that are locked SELECT * FROM table WHERE recordLock !='1' -
print the query to the screen to make sure it looks ok. Die if the query produces an error: // does the query look ok - if ok then comment out and run the query below print $query1; // run the query $result = mysql_query($query1) or die(mysql_error());
-
$tables = array('sandra','tomas','sebastian'); $totals = array(); foreach($tables as $table) { $prissum = "SELECT SUM(pris) AS pris FROM ".$table; $sum = mysql_query($prissum) or die('Error, query failed'); $totals[$table] = mysql_result($sum, "pris"); } // now you have the 3 totals // array('sandra' => 2804, 'tomas' => 700, 'sebastian' => 900) print_r($totals); // do your math $grandTotal = 0; foreach($totals as $total) { $grandTotal = $grandTotal+$total; } print $grandTotal;
-
You are using the POST array and not the SESSION $query1 = "SELECT * FROM Job_Spec WHERE Project_Name ='" . mysql_real_escape_string($_POST['job']) . "'"; $query1 = "SELECT * FROM Job_Spec WHERE Project_Name ='" . mysql_real_escape_string($_SESSION['job']) . "'";
-
$query=mysql_query("SELECT names FROM employee WHERE status='Active'"); $names = array(); while($row = mysql_fetch_object($query)) { $names[] = $row->names; } echo implode(", ", $names);
-
[SOLVED] Group XML output as groups from MySQL
JonnoTheDev replied to sonnyb's topic in PHP Coding Help
Could do or just order all clips by client ID. In a loop when the client ID changes then close the node and create a new node. So your database results returned may look like clipId clientId author Title 1 1 joe xxxxxxxx 2 1 joe xxxxxxxx 3 1 joe xxxxxxxx 4 2 phil xxxxxxxx 5 2 simon xxxxxxxx -
String Replace and Arrays not working properly
JonnoTheDev replied to patriotfan's topic in PHP Coding Help
I don't know how your translation code looks but this works $orig = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'); $new = array('aa', 'b', 'cC', 'de', 'E', 'f', 'gj', 'h', 'i', 'j', 'k', 'll', 'm', 'n', 'oo', 'pe', 'qu', 'r', 'z_', 'te', 'u', 've', 'wu', 'x', 'y', 'ze'); $string = "chris"; $keys = array(); for($x = 0; $x < strlen($string); $x++) { $key = array_search(substr($string,$x,1), $orig); $keys[] = $key; } foreach($keys as $key) { $newString .= $new[$key]; } print $newString; -
[SOLVED] Group XML output as groups from MySQL
JonnoTheDev replied to sonnyb's topic in PHP Coding Help
You do not want to group them as that will only give you a count of the number of clips per client. You either want to order the records by client or search for a specific client i.e WHERE client_id='x'