
Skewled
Members-
Posts
387 -
Joined
-
Last visited
Everything posted by Skewled
-
Mysql_Num_rows not working with die statment or if statment
Skewled replied to mike12255's topic in PHP Coding Help
You can't have any output before the header change, so you can't echo anything at all. You could do an ELSE and then perform your echo statements. -
Transferring Data to new PHP on clicked link
Skewled replied to nmrudolph's topic in PHP Coding Help
Your welcome, make sure you click this solved. -
Transferring Data to new PHP on clicked link
Skewled replied to nmrudolph's topic in PHP Coding Help
Move that entire $emaillink = ......... to under this line like so: while($state_row = mysql_fetch_array($state_results, MYSQL_BOTH)) { $emaillink = "<a target='main' onclick=window.open('contactform/contactCentral.php?name=$state_row[state].&firstname=$state_row[first_name].&lastname=$state_row[last_name]','popup','width=380,height=400,scrollbars=no,resizable=no,toolbar=yes,directories=no,location=no,menubar=yes,status=no,left=0,top=0'); return false>"; -
Sorry was very late, but I said you needed to add ; to the line but fell short of telling you which one... You're not adding ; to the end of this line: header("location: Admin_main.php") You need to: header("location: Admin_main.php");
-
Transferring Data to new PHP on clicked link
Skewled replied to nmrudolph's topic in PHP Coding Help
<?php echo $_GET["name"]; ?> Should be: <?php echo $_GET["firstname"]; ?> <?php echo $_GET["lastname"]; ?> Since that's what we're sending. As for displaying it in the title bar for the webpage for that window I dunno. -
Transferring Data to new PHP on clicked link
Skewled replied to nmrudolph's topic in PHP Coding Help
Not sure I follow clearly on what you want(I'll try to atleast help), but you could possibly just add it to $emaillink to call the $_GET variable later on. $emaillink = "<a target='main' onclick=window.open('contactform/contactCentral.php?name=$state_row[state].&firstname=$state_row[first_name].&lastname=$state_row[last_name]','popup','width=380,height=400,scrollbars=no,resizable=no,toolbar=yes,directories=no,location=no,menubar=yes,status=no,left=0,top=0'); return false>"; And this should just stay as it is: echo " $emaillink Contact $state_row[first_name] </a></span></li>\n"; Then on your contactCentral.php you can get the information from $_GET for first name and last name and do whatever it is you wish to do with them. -
Should be: if ($_SESSION['user_lvl'] == 1) { header("location: Admin_main.php") } else if ($_SESSION['user_lvl'] == 2) { header("location: Powuser_main.php"); } else { include ('erroruser.php'); } You had an extra } along with no ; for ending that line. header("location: Powuser_main.php")};}else {
-
http://php.about.com/od/learnphp/ss/php_forms.htm - Single Form http://webdesign.about.com/od/forms/a/aa072699multi.htm - Multiple Forms That will get you started, then you can move on from their to more advanced forms. Sorry I don't have the time to teach you all that you ask.
-
session_register("user_lvl") ==1; $_SESSION['name1'] = $rec[1]." ".$rec[3]; $_SESSION['id'] = $rec[0]; $_SESSION['ok'] = 1; header("location: Admin_main.php"); Do you have a user_lvl field in your database? $rec['user_lvl'] as an example First: $_SESSION['user_lvl'] = $rec['user_lvl']; Then: Assign your $_SESSION variables and then use either a IF/ELSE or SWITCH/CASE to step through your user_lvl's. if ($_SESSION['user_lvl'] == 1) { // header to load the admin page } elseif ($_SESSION['user_lvl'] == 2) { // header to load next page } else { // header to load the user level page }
-
walks away with head down, how did I not spot that!
-
So try this: <a href='viewprofile.php?= ' . $info['username'] . '><img src='http://datenight.netne.net/images/".$info['img'] ."' width='50' height='50''></a> ". " " . $info['username'] . " " . "says " . $info['status'] . "<br> <hr>"; That way when they click the link you'll pass the username over, just // comment out your link and paste this one under it. If it works yay, if not you still have the original.
-
I don't know how your accessing the script below, are you clicking a link to view the user? If you are then are you sending $_GET? I fixed the below code you didn't end the If/Else loop properly. <?php session_start(); $myusername=$_SESSION['myusername']; require "database.php"; if (!isset($_GET['username'])) { $data = mysql_query("SELECT * FROM users LEFT JOIN status ON status.username=users.username WHERE status.username = '".$_SESSION['myusername']."' ORDER BY id DESC LIMIT 1;") or die(mysql_error()); } else { $getuname = mysql_real_escape_string($_GET['username']); $data = mysql_query("SELECT * FROM users LEFT JOIN status ON status.username=users.username WHERE status.username = '".$getuname."' ORDER BY id DESC LIMIT 1;") or die(mysql_error()); } while($info = mysql_fetch_array( $data )) { //Outputs the image and other data Echo '<form name="newmsgfrm" method="post" action="new_message.php">'; Echo '<input type="submit" value="Send a New Message">'; Echo '</form>'; Echo "<img src='http://datenight.netne.net/images/".$info['img'] ."' width='150' height='250''> <br>"; Echo "<b>Name:</b> ".$info['username'] . "<br> <hr>"; }
-
Everything remains the same you just have to change WHERE username to: WHERE status.username Also, that example I gave you isn't going to work unless your using $_GET to load the profile page and passing username to the script, and I'm assuming that your using $_SESSION variables. So you should take it as just an example and not try to plug it into exsisting code.
-
<?php // The form is using a submit button named submit so we have to check to see if that was triggered by using // the below if statment with isset() if (isset($_POST['submit'])) { // place $_POST['input'] into a variable // Your form input field is named input so when the submit button is clicked above (if) statment is triggered // and $_POST contains the information for that input, I'm simply placing it into a variable so I can keep it organized // and then pass it to the query $value = mysql_real_escape_string($_POST['input']); // Added some security $sql = "INSERT INTO student (sname) VALUES ('".$value."')"; // I'm not an expert at sql syntax but I'm going to say it's safe to say $value needs to be escaped. mysql_query($sql) or die('Error:' . mysql_error()); // You don't need an IF for mysql_query you can just do it like this } mysql_close($link); // Close the connection to the database link ?> I just didn't put the mysql_close in the code I posted, it's always a good practice to close connections when your finished with them. In your code $value = (isset($_POST['input'])) would do the samething but your just dumping whatever the user types into your database and that's a NO NO. By breaking it down you can apply security and error checking much easier. I applied some security to the $value variable in the above code, nothing fancy though. I hope I answered all your questions, if I missed something just let me know!
-
opps forgot the JOIN WHERE username = '".$username."' Should be: WHERE status.username = '".$username."' That should do it.
-
$data = mysql_query("SELECT * FROM users LEFT JOIN status ON status.username=users.username WHERE username = '".$username."' ORDER BY id DESC LIMIT 1;") or die(mysql_error()); $username could be from a $_GET variable and default to a $_SESSION variable when your viewing your own status, if that makes sense. Here's a $_GET example using a $_SESSION variable to determine who is viewing the page and what information should be displayed. <?php // Let's pretend you have a session saved when a user logs into the site and it's set to // $_SESSION['username'] // This should work if you're passing the username in a url link to the script where your // going to be viewing the user status if (!isset($_GET['username'])) { $data = mysql_query("SELECT * FROM users LEFT JOIN status ON status.username=users.username WHERE username = '".$_SESSION['username']."' ORDER BY id DESC LIMIT 1;") or die(mysql_error()); } else { $getuname = mysql_real_escape_string($_GET['username']); $data = mysql_query("SELECT * FROM users LEFT JOIN status ON status.username=users.username WHERE username = '".$username."' ORDER BY id DESC LIMIT 1;") or die(mysql_error()); } // go on with your bussiness here for how you deal with the data // Like fetching an array from the above query and displaying the results how you // see fit ?> Given the original query you'll always be pulling the first row from the database each time. Hope that helps!
-
http://www.tizag.com/mysqlTutorial/mysqljoins.php That's a small tutorial on using JOINS I would recommend that you also check out the documentation on MySQL here: http://dev.mysql.com/doc/refman/5.5/en/join.html
-
$data = mysql_query("SELECT * FROM users LEFT JOIN status ON status.username=users.username ORDER BY id DESC LIMIT 1;") or die(mysql_error()); //Puts it into an array while($info = mysql_fetch_array( $data )) { Using a JOIN to link the tables, give it a shot.
-
<?php if (isset($_POST['submit'])) { // place $_POST['input'] into a variable $value = $_POST['input']; $sql = "INSERT INTO student (sname) VALUES ('$value')"; if (!mysql_query($sql)) { die ('Error: ' . mysql_error()); } } ?> make the following adjustment and you should be good to go.
-
http://stackoverflow.com/questions/3261069/how-to-grab-mysql-data-into-a-multidimensional-array Perhaps this will be more helpfull
-
http://bytes.com/topic/php/answers/835140-mysql-table-php-multidimensional-array http://www.brainbell.com/tutors/php/php_mysql/Multidimensional_Arrays.html Check this out see if it points you in the right direction.
-
users using fire fox may have issues going to my forum.
Skewled replied to ufo8mycow's topic in PHP Coding Help
This is most likely a styling issue rather then a PHP issue. -
Multiple fields in Form PHP/HTML to email... fail
Skewled replied to Bloodmorphed's topic in PHP Coding Help
If you want to work with the $_POST array the you need to read: http://php.net/manual/en/reserved.variables.post.php In the first example submitted by a user you'll see how to do this. Give it a shot. -
Add your link to mysql_affected_rows($dblinkhere); You'll have to place the link that holds that connection where $dblinkhere is. This is what I ment but kept the $result1 there for no reason. mysql_affected_rows() works just like that .. so whatever the last mysql_connect() database was, will be the link identifier. So on your last query $result1 was not the link identifier and that's why it flagged you with the warning. So using the mysql_affected_rows($dblinkhere); or mysql_affected_rows(); would both work. Don't forget to mark solved.