sanfly
Members-
Posts
344 -
Joined
-
Last visited
Everything posted by sanfly
-
Okay, Im trying to ignore the fact that I cant make head nor tails of what youre trying to do here, and just concentrate on the code itself. Firstly, are you getting any output at all?
-
Can you post your code as you currently have it please
-
Well, firstly i would put my connection data in a different file, that can be easily included each time its needed eg: db.php <?php $db_host = 'localhost'; $db_user = '*****'; $db_pass = '*****'; $db_name = '*****'; $conn = mysql_connect($db_host,$db_user,$db_pass) or die("Cannot Connect to database"); $db = mysql_select_db($db_name,$conn) or die("Could not select database"); ?> Then I would do the select box as below <form name="form1" method="post" action="message1.php"> <select name="selectUser" size="1"> <? include "db.php"; $result = mysql_query("SELECT * FROM userdata") or die(mysql_error()); while($row = mysql_fetch_array($result)) { $userid = $row['userid']; $username = $row['username']; // depends on what your field is called ?> <option value='<?=$userid?>"><?=$username?> <? } ?> </select> <br><br> <input type="submit" name="Submit" value="Submit"> </form>
-
[SOLVED] What's wrong with my code, should be simple.
sanfly replied to mr_badger's topic in PHP Coding Help
Your problem is here if($a%5 == 0 && $a%10 != ) { you need to have something after the != if you want it to equal nothing, put two apostrophes eg if($a%5 == 0 && $a%10 != '') { -
in your query use "ORDER BY clicks DESC LIMIT 5" $r = mysql_query("SELECT * FROM mytable ORDER BY clicks DESC LIMIT 5"); $row = mysql_fetch_array($r); while($row = mysql_fetch_array($r)){ $url = $row['url']; $title = $row['title']; $clicks = $row['clicks']; // put the data into the table here }
-
I think for something like this you would need to use UNION $query = "(SELECT * FROM call_reminder WHERE date >= '$todays_date' AND date >= '$start_date' AND date <= '$end_date' AND call = 'Bonus Call' AND level = 1 AND member_group = '$member_group') UNION (SELECT * FROM call_reminder WHERE date >= '$todays_date' AND date >= '$start_date' AND date <= '$end_date' AND call = 'Bonus Call' AND level = 1 AND member_group = 'all') ORDER BY date ASC"; Also, if you have any trouble with the date fieldname, put backticks around date eg: `date` (MYSQL Reserved Words)
-
First you need to read the entire file into an array using file() $array = file("path/to/file/myfile.txt"); The you need to use explode() to get the timestamps into seperate values Since the info we put into $array is in an array, then we need to use the first array value to do this step $data = explode(' ',$array[0]); Now you can access all your first three data points (remember arrays start at 0) $point1 = $data[0]; $point2 = $data[1]; $point3 = $data[2]; This code below may help you see how it all works. It prints out the arrays so you can see what Im talking about Substitute "test.php" for your file name <? $array = file("test.php"); print_r($array); echo "<br><br><br><br>"; $data = explode(' ',$array[0]); print_r($data); echo "<br><br><br><br>"; echo $data[0]; echo "<br><br>"; echo $data[1]; echo "<br><br>"; echo $data[2]; echo "<br><br>"; ?>
-
I would recommend using the help FAQs or forum on the site you got the script from
-
<? $_SESSION['username'] = $_POST['username']; ?> etc....
-
This is more or less how I would do it, keeping as much to your old script as possible. Regarding your old script, I couldnt work out why you were using the switch in there? Anyway.... Please note I have left a space where you need to update the session values after the insert <?php ob_start(); session_start(); //include config.php file include('../config.php'); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <style> .words { background-color:#16333B; color:#A9D033; } </style> <?php $p = $_GET['p']; //see my ?id= browsing tutorial if(!isset($_SESSION['username'])){ ?> <form action='../login.php' method='POST'> You Must Be logged in to View this page!<br> Login here:<br> Username: <input type='text' name='username' class='words'><br> Password: <input type='password' name='password' class='words'><br> <input name='login' type='submit' value='Submit' class='words'><br> Not <a href="../register.php">registered</a>? </form> <?php exit(); } else{ if($_POST['update']){ // Get Posted Variables... $fullname = $_POST['fullname']; $password = md5($_POST['password']); $aboutme = $_POST['aboutme']; $email = $_POST['email']; $id = $_SESSION['id']; // Get Sandy's record from the "example" table $result = mysql_query("UPDATE users SET fullname = '$fullname', password = '$password', aboutme = '$aboutme', email = '$email' WHERE id = '$id'") or die(mysql_error()); // wILL NEED TO UPDATE THE SESSION VALUES HERE echo "<B>Profile Updated</B><br><br>"; ?> <form name="update" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <table cellpadding="2" cellspacing="1" width="400"> <tr> <td wdith="35%">Username:</td> <td><?php echo $_SESSION['username']; ?></td> </tr> <tr> <td>Full Name:</td> <td><input type="text" name="fullname" value="<?php echo $_SESSION['fullname']; ?>" /></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password" value="" /></td> </tr> <tr> <td>About Me:</td> <td><textarea height="200px" width="300px" input type="text/html" name="aboutme" value="" /><?php echo $_SESSION['aboutme']; ?></textarea></td> </tr> <tr> <td>Email Address:</td> <td><input type="text" name="email" value="<?php echo $_SESSION['email']; ?>" /></td> </tr> <tr> <td colspan="2"><input type="submit" name="update" value="Update Profile" ></td> </tr> </table> </form> <? } ?>
-
[SOLVED] wont insert anything into my mysql database
sanfly replied to laron's topic in PHP Coding Help
Well, I guess its probably not permissions then. Its going to be hard to diagnose the problem without error reporting switched on. Heard anything from your webhost yet? I just had a thought. Are you using addslashes() on your values before you insert them into the database? Perhaps there is an apostrophe or something in the data that is tripping things up? -
I dont think it can be done strictly with php, but maybe you could do something with AJAX? Try googling for it perhaps? There is a loading message tutorial HERE but I dont know about a dynamic moving loading bar
-
[SOLVED] wont insert anything into my mysql database
sanfly replied to laron's topic in PHP Coding Help
Maybe I guess, but I would think on a commercial server all accounts would have access Do you have phpMyAdmin (or something similar) access? Try going in there and inserting the query using the SQL window. I would think that error reporting in phpMyAdmin would be on by default? -
There was a space, directly after the "Yes" or "No"
-
Sorry, I dont understand what you mean
-
Try replacing this part $boxes = array('Txt1' => "$_POST['Txt1']", 'Txt2' => "$_POST['Txt2']", 'Txt3' => "$_POST['Txt3']", 'Txt4' => "$_POST['Txt4']", 'Txt5' => "$_POST['Txt5']"); with this $boxes = array('Txt1' => $_POST['Txt1'], 'Txt2' => $_POST['Txt2'], 'Txt3' => $_POST['Txt3'], 'Txt4' => $_POST['Txt4'], 'Txt5' => $_POST['Txt5']);
-
Works for me Did you press ctrl + F5 to refresh the page?
-
Can you indicate the code from lines 65 - 70 please
-
Can you post your ENTIRE code please
-
Yep, sorry, forgot to double up the = signs Should be: <td><select name="Combo2" size="1" class="WorkPageField" id="Combo2"> <option value="Yes" <? if($theValue == "Yes"){ echo "selected"; } ?>>Yes</option> <option value="No" <? if($theValue == "No"){ echo "selected"; } ?>>No</option> </select></td> Dont forget to ctrl+F5 to refresh the page after making the changes. You need the form to reset itself properly
-
[SOLVED] AHHH...page cannot find header or footer file?!?
sanfly replied to scott089's topic in PHP Coding Help
Youre welcome Make sure you hit the SOLVED button in this thread -
Wait, Ive just discovered that <?php=$var?> only works with short tags ie: <?=$var?> Try using echo instead <?php echo"$latitude"; ?> and <?php echo "$longitude"; ?>
-
Take out those spaces should be exactly as I posted first