pocobueno1388
Members-
Posts
3,369 -
Joined
-
Last visited
Never
Everything posted by pocobueno1388
-
You never defined $row. <?php //Start session session_start(); //Connect to mysql server $link=mysql_connect("localhost","###","###"); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db=mysql_select_db("bbmembers"); if(!$db) { die("Unable to select database"); } $userid = $_SESSION['SESS_MEMBER_ID']; $qry="SELECT * FROM members WHERE id='$userid'"; $result=mysql_query($qry); if (mysql_num_rows($result) > 0){ $row = mysql_fetch_assoc($result); echo $row['firstname']; } else { echo "No results found in the DB"; } ?>
-
<?php $userID = $_SESSION['ID']; $query = "SELECT * FROM table WHERE userID='$userID'"; $result = mysql_query($query); ?> To echo the ID, you would just do this. echo $_SESSION['ID'];
-
Try mysql_fetch_assoc() instead of array. Show the code to your drop-down.
-
Are there any files included? The function could possibly be in one of those files. When you take out: echo password('$password'); Do you get an error in the code, or does it work fine?
-
Simple Example of Check Box to update MySQL Field NeededMy Links
pocobueno1388 replied to woocha's topic in PHP Coding Help
<?php if (isset($_POST['submit'])){ //check if they put yes to pepsi if (isset($_POST['y_pepsi'])){ //update DB to '1' } } ?> <form> Do you like Pepsie? <input type="checkbox" name="y_pepsi"> Yes <input type="checkbox" name="n_pepsi"> No <p> <input type="submit" name="submit"> </form> Is that what your looking for? -
What do you mean "nothing". Is there at least a text box showing up? Or is the text box not showing the $value variable, if not then your variables don't hold a value.
-
I don't see how it's possible not to mix the two. The HTML is for formatting, and the PHP is for the sites function. If you have to organize your data that comes from PHP into a table, what are you going to do, include a file that opens your table, then include another file that closes it? It wouldn't make sense not to mix them. You could have a PHP class that calls the HTML, then whenever you want to edit the HTML you just go into the class and edit it.
-
[SOLVED] when GET cannot find anything in the database?
pocobueno1388 replied to marco839's topic in PHP Coding Help
You just check if the query returned any results. <?php if (mysql_num_rows($query) < 1){ echo "Sorry we have no record"; } else { //code to display record data goes here } ?> -
echo "<tr><td>$field:</td><td><input type='text' field='$value' value='$value' /></td></tr>";
-
PHPfreaks has a tutorial on this, and there are plenty out there if you google it. http://www.phpfreaks.com/tutorials/73/0.php
-
Post the code you have, also tell us what type of DB field is it?
-
Reloading the page with updated query string values
pocobueno1388 replied to enchance's topic in PHP Coding Help
You didn't answer the question... -
Are you sure your typing the correct path in the address bar? Give us he exact path to your script, then tell us what your putting in the address bar.
-
Reloading the page with updated query string values
pocobueno1388 replied to enchance's topic in PHP Coding Help
Well, are you wanting the page to reload without having to refresh the browser? If that is what your after, your going to need AJAX or JavaScript. If it doesn't matter if the page has to refresh, then the method I supplied should work fine. -
Reloading the page with updated query string values
pocobueno1388 replied to enchance's topic in PHP Coding Help
Sounds like your on the right path. $thisimage = $_GET['imagenumber'] should be placed above the line where you display the image, as long as you have that, you should be good. Yes, because it will know what array value to pull by taking it from the URL. <?php $images = array("1.jpg", "2.jpg", "3.gif"); $thisimage = (isset($_GET['imagenumber']) ? $_GET['imagenumber'] : 0; echo "<img src='".$images[$thisimage]."'>"; ?> -
Are the people voting required to be logged into an account? If so, that would make this whole thing easier. If they don't need to be logged in, then you might have some issues with this. You could log IP addresses, but some people have the same one, plus they are always changing...so that wouldn't work very well.
-
Your going to have to explain better than that.
-
How do I... (PHP. Searching Functions?)
pocobueno1388 replied to d22552000's topic in PHP Coding Help
http://php.net/strstr http://www.php.net/manual/en/function.strpos.php http://www.php.net/manual/en/function.strrchr.php Those are all string searching functions. -
<?php if (eregi('Y', $setts['enable_cat_counters'])) echo ($catBrowse['items_counter']!=0)."(".$catBrowse['items_counter']."".$catBrowse['items_counter'].")"; ?>
-
echo ($catBrowse['items_counter']!=0)."(".$catBrowse['items_counter'].")".$catBrowse['items_counter'].")";
-
Whats the ":" in the middle for? If your trying to display that, you need to have it between the quotes. Try this: ".$catBrowse['items_counter'].")".$catBrowse['items_counter'].")"; If thats not right, give an example of what you want the display to look like. Also, show the rest of the code that goes along with that.
-
[SOLVED] Server switch- "continue" not working?
pocobueno1388 replied to kernelgpf's topic in PHP Coding Help
Are you sure you don't have another loop surrounding the while loop? Why do you have all those continues in there? It should do just fine without them. I tested your code on my server, just replaced everything with my DB information and it worked fine. -
<?php $query = "SELECT date, description, user_id, ip_addr, data_id FROM table"; $result = mysql_query($query)or die(mysql_error()); while ($row = mysql_fetch_assoc($result)){ echo $row['date'].'<br>'; echo $row['ip_addr'].'<br>'; echo $row['description'].'<p>'; } ?> That will display the data like you listed above. You might have to format your date/time how you want it, I'm not sure how you have that stored in the DB.