wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
Remove the equals sign before IN() on this line $query = sprintf('SELECT Pid, Pname FROM People WHERE Pname = IN(\'%s\')', implode('\',\'', $authArray)); Dont forget to remove die('here');. Now it should function as intended.
-
Sorry about that. I also made another mistake $sqlValues[] = sprinf("(%d, %d, now(), 0)", $PId , $PCorder++ ); The above should read $sqlValues[] = sprintf("(%d, %d, now(), 0)", $PId , $PCorder++ );
-
You've got it all wrong. $get["status"][0] = "Waiting for support..."; $get["status"][1] = "Waiting for user..."; $get["status"][2] = "Ticket Closed..."; $get["status"][3] = "Ticket Opened..."; Here you're overwriting the value coming from your database ($get['status']) as you're redefining the variable $get['status'] to an array, variables with the same name cannot store two different values. This is why I suggested you to define your various status messages within a separate array ($status), as I posted earlier $status[0] = "Waiting for support..."; $status[1] = "Waiting for user..."; $status[2] = "Ticket Closed..."; $status[3] = "Ticket Opened..."; Now the variable $get['status'] holds the array index that corresponds to a status message within the $status array. To display the status message you'd use echo $status[$get['status']]; So if $get['status'] is set to the value of 2, then the above will display "Ticket Closed...", if it was set to 1 then it'll display "Waiting for user..." etc.
-
Then it should be able to write the xml file then.
-
And you're still getting the error? What permission is the parent directory (majorassignment) set to?
-
What file permissions have you applied to course1results.xml? PHP cannot open/write to the file due to the file permissions. If you are creating the file you'll also need to apply the necessary write permissions to the parent directory too Also when you post code could you wrap it within code tags ( or ).
-
I did not know this, Thank you Mr wildteen88. I just learnt that from reading the manual, ha
-
I dont think the code we are seeing is the problem. As my code suggestion should not be causing an infinity loop no matter may many rows you have in your table. I think the issue lies elsewhere in your code.
-
The code posted by Ruzzas is not the correct wayto loop through the results returned from a query. My suggestion is the correct way. If that is causing an infinity loop then I dough it is the problem code, how do you know that is causing the problem?
-
In your printf_array function make it call sprintf function printf_array($Format, $Array) { return call_user_func_array('sprintf', array_merge((array)$Format, $Array)); } printf will return the length of the outputted string. sprintf will return the formatted string
-
Or use the DOM object. $doc = new DOMDocument(); $doc->loadHTMLFile("filename.html"); $xpath = new DOMXPath($doc); $entries = $xpath->query('//html/head/title)'; echo $entries->item(0)->nodeValue;
-
Always use full PHP (tag) syntax, that way issues like this will never arise. Tags such as <? ?> or <?= ?> will only be available when a setting called short_open_tag is enabled.
-
You're using a bitwise comparison operator & here if($Log['Revision1']&$Log['Revision2']){ I think you meant to use &&
-
Move mysql_query("SELECT * FROM xhost_boxs") outside of the loop. So its $result = (mysql_query("SELECT * FROM xhost_boxs"); while($CurrentServers = mysql_fetch_array($result)) { echo $CurrentServers['box_id']; } Otherwise you've got yourself an infinity loop, as PHP will keep on executing the query on every loop.
-
What happens when you run it?
-
How to parse 'time()' to a human readable format?
wildteen88 replied to ChrisMartino's topic in PHP Coding Help
Yes, pass the unix timestamp as the second argument to the date function. Using date() you can format the timestamp to your needs, eg $timestamp = time(); echo date('g:i A', $timestamp); -
Add $rank = 1; before this line while($ds=mysql_fetch_array($participants)) { $teamID = $ds['clanID']; Now change } } }echo '</table>'; to } $rank++; } }echo '</table>';
-
You could have a look at this post I made a while back for resizing an uploaded image into three different sizes. http://www.phpfreaks.com/forums/index.php/topic,145498.msg622544.html#msg622544
-
What is your current code. You will only need to add one or two lines of code at most for this.
-
You should write your function like this class People { public function insertAuthor() { $authArray = array_map('mysql_real_escape_string', $_POST['author']); $query = sprintf('SELECT Pid, Pname FROM People WHERE Pname = IN(\'%s\')', implode('\',\'' $authArray)); $result = mysql_query($query); if($result && mysql_num_rows($result) > 0) { $PCorder = 0; $sqlValues = array(); while(list($PId, $PName) = mysql_fetch_row($result)) { if(in_array($PName, $authArray)) $sqlValues[] = sprinf("(%d, %d, now(), 0)", $PId , $PCorder++ ); } $sql = "INSERT INTO PeopleCon(Pid, PCorder, PCdateadded, PCdeleted) VALUES \n"; $sql .= implode(",\n", $sqlValues); echo "Generated SQL Query:<pre>$sql</pre>"; $result = mysql_query($sql); } } }
-
Anchor tags (<a></a>) don't have an action attribute. If you're wanting to set the cookie when the user clicks the link/image then you'll need to use Javascript for this. Here is a tutorial on using cookies with Javascipt. PHP will be able to read cookies set by javascript (and vise versa)
-
This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=306650.0