davidannis
-
Posts
627 -
Joined
-
Last visited
-
Days Won
2
Posts posted by davidannis
-
-
Note that you can always access superglobals like $_SESSION inside a function even if the variable is not passed in.
-
The line
$result = sqlCall($con, "SELECT * FROM Servers");
is running the query that the fetch_array tries to get the data from. If the query succeeds, the variable $results contains an object. If not, it contains a boolean false. So the query is failing. You need to see what error mysql is returning and fix that.
-
Why does the second query contain Events.Faith_ID but the first does not (the Join is different too)?
-
The display block in the error condition does not have a <tr> <td> tags and is displayed i the middle of the table. Perhaps the browser doesn't know how to display it. View source and see if it is there.
-
Lazro. I'm not a MySQL expert so I don't understand how you know his database structure. All you have is the field names from his query. What am I missing that allows you to duplicate the database?
-
I would start by echoing $verify_Event_sql and running it against the database perhaps in phpMyAdmin to see what results you get. Then do the same with $get_Event_sql. Perhaps the second query is not producing results because it looks like the first query counts all events in the current month (Day is not considered) but
WHERE DAY(Events.Event_Date)= Day(Now()) And MONTH(Events.Event_Date)=Month(Now()) And YEAR(Events.Event_Date)=YEAR(Now())
looks at only events happening today.
-
If you don't want a single person viewing a profile to be counted twice you can either store each view in a database (works with logged in users across browsers and machines) or store who's been looked at in a cookie (works without requiring a login but only within individual browsers so if the user looks at the office and home he is counted twice) or you can use both mechanisms if you have both logged in and non-logged in users.
-
sometimes you get more. Hopefully I can deliver.
Here's my pitch. If you represent a charitable organization, a 501c(3) recognized by the IRS, I will consider taking on projects or just helping with small changes, project planning and management, quality control, etc. for free. Please read my profile first to see what I have done and my skills. I won't take projects that are on tight deadlines (I do have a day job, a wife, and three children) or for organizations that advocate for things I don't believe in.
I will have time beginning in mid-July. Contact me via private message.
Not interested in programming for commercial ventures even if you pay me.
David
-
Capitalization
-
Does the file name end in .php? If not perhaps godaddy is displaying it as html.
-
It should be possible. Use a loop. Pseudocode:
$perm_conn=mysqli_connect(...combined_data); truncate combined data // make sure you start with an empty table $databases=Array('db0', 'db1); foreach ($databases as dbname){ connection=mysqli_connect....$dbname); $select=//your select goes here $result=mysqli_query($select); while $row=mysqli_fetch_assoc($result){ //clean up here and/or at end //write $row to perm_conn here; } close connection to $dbname and free $results here (don't want 100 open connections) } //clean up, dedupe and send here
Actually I like PravinS approach better, which you can also do in a loop.
-
I think that you want to capture the content of the output buffer http://php.net/manual/en/function.ob-get-contents.php
-
try putting the variable in curly braces
{$array[i]}
from the php echo page examples:
// You can also use arrays
$baz = array("value" => "foo");
echo "this is {$baz['value']} !"; // this is foo ! -
No it shouldn't.You are thinking of mysqli_query()
Oops, my bad. I almost exclusively use mysqli. Should have advised the OP to switch to mysqli since mysql is deprecated.
-
On the last line the variable should be $results and the connection variable should be before the query variable. You should also sanitize the data before the query.
-
the place you put it in post 6 seems seems fine to me.
Also, when you post code please use the code tags (the "<>" symbol in the editor). It will make your code easier to read.
-
Looks like your host does not let you include files that are in certain directories (probably those above /home/a1632545/public_html) as a security precaution. That way if I can get a webpage on your server I can't do things like
include '/etc/passwd' ;
If you move the files you want to include to a directory like /home/a1632545/public_html/includes it should fix the problem.
-
You can make a program that serves the mp3 file only if the link has not already been used.
Here's how I'd do it:
When a link is created for a user create a random number and store it in a database along with the link id (autoincrement) and the name of the file to serve.
Then output a link that looks like this http://mydomain.com/servefile.php?id=12345&key=734871637846
when servefile.php runs it will read the database
$id=mysqli_realescape_string($dbconn, $_GET['id']) ; $query="SELECT * FROM tablename WHERE id=$id"; $result=mysqli_query($query); $row=mysqli_fetch_assoc($result); if ($row['key']==$_GET['key'] && $row['used']!=true ){ //serve file here and mark link as used in database }else{ // print an error message here; }
-
The link should look like this (in context in viewmsg.php
<b><p><a href="inbox.php">Inbox</a> | <a href="compose.php">Compose</a> |<a href="compose.php?replyto=<?php echo $sender?>">Reply to this message</a> | <a href="sent.php">Sentbox</a></b> <b><p><?php echo "$pm_count"." of 50 Total | "."$percent"."% full"; ?></p></b>
Then in compose try something like:
else { if ($_GET['replyto']!='') $receiver=$_GET['replyto']; //Here's the form for the input ?>
-
I'd just make a link back to compose.php?replyto=$sender and then use the $_GET['replyto'] to address the message. Try it and we'll help with bugs.
-
Did you include the line
<?php
You shouldn't. You're already in php.
-
This might also be worth checking out http://pear.php.net/reference/PhpDocumentor-latest/Cpdf/Cpdf.html#class_details
-
I have used fpdf and smarty templates to do what you described. There is also http://www.tcpdf.org/ http://sourceforge.net/projects/pc4p/ and http://sourceforge.net/projects/pdf-php/
-
Instead of calling the function each time:
Door : <select name="door" > <option>----</option> <option value="white" <?php if(get_value('door') == "white") { echo 'selected="selected"'; } ?> >white </option> <option value="red" <?php if(get_value('door') == "red") { echo 'selected="selected"'; } ?> >red </option> </select>
you can call it once and use the return value multiple times which will be more efficient:
Door : <select name="door" > <?php $door_val=get_value('door')?> <option>----</option> <option value="white" <?php if($door_value == "white") { echo 'selected="selected"'; } ?> >white </option> <option value="red" <?php if($door_value == "red") { echo 'selected="selected"'; } ?> >red </option> </select>
another strategy is to store the values of the colors in an array and then loop through it to create the select. That way, if you want to add 20 more colors you just add them once and don;t have a ton of code:
Door : <select name="door" > <?php $door_val=get_value('door'); $door_colors=Array ('blue','green','red'); ?> <option>----</option> <?php foreach ($door_colors as $color){ echo '<option value="'.$color.'" '; if ($color == $door_val) echo "selected=\"selected\""; echo ">$color </option>"; }
variables between multiple functions
in Applications
Posted
I am not advocating that you use superglobals as a way to pass data in and out of functions, just pointing out that they break the rule of encapsulation.
When I have a lot of values to pass out of a function my approach is often to build an array and use the array as a return value. What do you think of that approach?