PHP - Simply Php Assistance
I'm pretty new to php... I need a short script that I can place at the top of my web page that does the following:
In theory, a person only be able to access page2.php unless they come directly from page1.php (The message that appear should say you are not authorized to access this page) I do not want to create login of any kind... Can you help? thanx in advance! Similar TutorialsThis topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=358137.0 I am looking for a really simple link directory script. Something similar to http://www.cygnusdirectory.com/ but with a banner on top. Any suggestions / recommendations ?
I am running three scheduled tasks on my website. I am only allowed three per day by my host. I want to add another one. Can I simply call another php program from within a php program which is currently running ? I have a registration form and there is a part for Phone Numbers / Email it's option for either. My question is : The Field is a VARCHAR 255 , the max you can input on that registration field is 20 Characters? HOW Can i change the value to more like 30 - 40 characters ? please help. Hi all! I am building a website, and the users can create a pet name. I only want them to be able to use letters, numbers and underscores in the names. How can I do this? Thanks! I would also be using this for the usernames as well. Here is my pet creation code: adopt.php: Code: [Select] <?php session_start(); include("config536.php"); ?> <html> <head> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <?php if(!isset($_SESSION['username'])) { echo "<banner></banner><ubar><a href=login.php>Login</a> or <a href=register.php>Register</a></ubar><content><center><font size=6>Error!</font><br><br>You are not Logged In! Please <a href=login.php>Login</a> or <a href=register.php>Register</a> to Continue!</center></content><content><center><font size=6>Messages</font><br><br></center></content>"; } if(isset($_SESSION['username'])) { echo "<banner></banner><nav>$shownavbar</nav><ubar>$ubear</ubar><content><center><font size=6>Adopt a Pet</font><br><br>"; $thedateis = date('F jS, Y'); $getpetid = $_GET['petid']; $adopt = $_POST['submit']; $petname = $_POST['petname']; $petgen = $_POST['gender']; $thebq = "SELECT * FROM pets WHERE petid='$getpetid'"; $theb = mysql_query($thebq); while($prr = mysql_fetch_array($theb)) { $pid = $prr['petid']; $species = $prr['pname']; $number = $prr['number']; } if(!isset($getpetid)) { $pq = "SELECT * FROM pets WHERE petid != '0'"; $p = mysql_query($pq); while($pr = mysql_fetch_array($p)) { $pid = $pr['petid']; $ptype = $pr['pname']; $im = $pr['pimage']; $number = $pr['number']; $limited = $pr['limited']; $types = $pr['types']; echo "<b>$ptype</b><br><a href=?petid=$pid><img src=/images/pets/$im></a><br>Number: $number<br><br>"; } } if(isset($getpetid)) { ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> Please select a Name: <input type="name" name="petname" maxlength="15"><br> Pet Gender: <select name="gender"><option value="female">Female</option><option value="male">Male</option><br><br><input type="submit" name="submit" value="Adopt Pet"></form> <?php $checkitq = mysql_query("SELECT * FROM userpets WHERE userpetname='$petname'"); $gcheckit = @mysql_num_rows($checkitq); $tq = "SELECT * FROM users WHERE username='$showusername'"; $t = mysql_query($tq); while($rw = mysql_fetch_array($t)) { $grabnum = $rw['pets']; } if(isset($adopt)) { if($grabnum >= "4") { echo "<font color=red>Error! You already have 4 pets.</font>"; } if($petname == "") { echo "<font color=red>Error! Please type in a name for your pet.</font>"; } if($qcheckit == "1") { echo "<font color=red>Error! That pet name already exists!</font>"; } if($gcheckit == "0" && $petname != "" && $grabnum < "4") { mysql_query("INSERT INTO userpets (owner, userpetname, userpetspecies, userpettype, petdatecreated, gender, strength, defence, health, level, booksread, smart, hunger) VALUES ('$showusername', '$petname', '$species', 'Normal', '$thedateis', '$petgen', '1', '1', '10', '1', '0', 'Normal', 'Full')"); mysql_QUERY("UPDATE users SET pets=pets+1 WHERE username='$showusername'"); echo "<font color=green>Success! Your pet has been created!</font>"; } } } } ?> </html> Thanks in advance for the help everyone!! I am trying to make a loop simply write "static" code...if that is the correct explanation.... But it seems PHP wants to "process" such things as 'IF' and other Conditions which is defeating the purpose. The problem specifically is that I NEED for a dynamic write to happen based on a variable that will put the following lines that start with IF (! isset // Make sure the checkbox arrays exist if (! isset($_POST['cp_checkbox_one'])) $_POST['cp_checkbox_one'] = array(); if (! isset($_POST['cp_checkbox_two'])) $_POST['cp_checkbox_two'] = array(); if (! isset($_POST['cp_checkbox_three'])) $_POST['cp_checkbox_three'] = array(); // here in the lines below is one way I have tried to make the the LINES ABOVE get written Dynamically // THIS PART returns the values I need, the checkbox names ---- // // foreach($_POST as $meta_key => $meta_value) { // if(cp_str_starts_with($meta_key, 'cp_checkbox')) { echo $meta_key; } // } // So that code WILL RETURN THE VALUES I NEED : // cp_checkbox_one, cp_checkbox_two, cp_checkbox_three // BASED ON THIS I WROTE THE FOLLOWING CODE-- BUT IT DOES NOT WORK AS A REPLACEMENT FOR A LINE // SUCH AS--- if (! isset($_POST['cp_checkbox_one'])) $_POST['cp_checkbox_one'] = array(); // function checkboxloop() { foreach($_POST as $meta_key => $meta_value) { if(cp_str_starts_with($meta_key, 'cp_checkbox')) { if (! isset($_POST[$meta_key])) $_POST[$meta_key] = array(); } } } // HERE I ASK FOR THE FUNCTION BUT WHILE I GET NO ERRORS I GET NO RESULTS // WHICH IS A PROPER SAVE OF UNCHECKED CHECKBOXES ON SUBMIT checkboxloop; I would very much appreciate knowing how to make the code keep looping whatever $meta_key names turn up on this page and then use those names to write the complete lines as STATIC PHP so that the IF conditions don't get "processed" while this function is called. In effect, I want to duplicate the effect of having the code lines WRITTEN, so that they perform exactly as if I had written them as PHP hard-code, as many lines as there will be $meta_keys, but not SEE the code--- just have it valid PHP. This function does NOT make the same thing happen internally. As soon as I replace the function with the HARD CODE PHP then it works...but, I have reached the stage where these lines of code have to happen dynamically. I am baffled how to get this to happen! If I use Echo then I get errors about the "IF". Thank you very much for your help! ok... I'm still struggling with PHP syntax, my editor's linting keeps flagging a line as incorrect. it's supposed to read as " when d1 minus 1 is less than or equal to d2 with d2 being less than or equal to d1 plus 1" so in other words its supposed to be true if d2 is between d1 minus 1 and d1 plus 1, inclusive. I don't want d2 being the previous number, the same number or the next number relative to d1. The same goes for d3, d4, and d5 (4 and 5 are un coded because why code in errors).
That being said... This isn't exactly my correct goal but I'm not sure how to code what I really want... I can't seem to find a good way to test this without the commands I know from other languages like CountIf, Iffn and RandSamp. (those are Ti-Basic commands) I know "please do it for me" is frowned upon, and hate saying it (I'd rather learn to do it myself), but if anyone can explain how to do this I'd really appreciate it. Edited March 23, 2019 by Karaethon I am trying to do a query for members in my database but I need to go through different tables to get those members I want. Let me try too describe: I want the members who has same team_id as current member (from same table) I want only the members who are online (from another table where time stamps are, which has members id, but not team id) I simply cannot figure out how to only get members with same team id as the current member, from the table with time stamps. Anyone can point me in the right direction, or is the above just not making sense at all? I'm trying to dissect a string using preg_match but I'm having a hard time understanding the tutorials (and the php manual). This is as far as I've gotten: Code: [Select] <?php $message = "EASTRIVANN RES STRUCTURE FIRE AD: 4966 TURKEY SAG RD CTY: AC LOC: ATAC4 FIRE IN STRUCTURE/ALARM CO CONFIRMED W/HOMEOWNER XST: 2751 BELL ACRES XST2: 2312 PETERS MTN RD"; $typepattern = ('/^EASTRIVANN /'); preg_match($typepattern, $message, $matches); if ($matches) { echo $matches[0]; }else{ echo 'No matches.'; } ?> My goal is to pull the following out of the string: Code: [Select] $alarmtype = "RES STRUCTURE FIRE"; $address = "4966 TURKEY SAG RD"; $county = "AC"; $location = "ATAC4 FIRE IN STRUCTURE/ALARM CO CONFIRMED W/HOMEOWNER"; $xst = "2751 BELL ACRES"; $xst2 = "2312 PETERS MTN RD"; I am them storing the values into a database for later retrieval. I've gotten as far as Matching EASTRIVANN but i'm not sure how to pull out the actual text between my anchors. Any help would greatly be appreciated Thanks Jason Long story short, this is my code: Code: [Select] <input type=radio id='s1' value='1' onclick='showPreview(1)' name='star' $value><label for='s1'><img src='style_images/1/icons/1.png'></label> <br> <input type=radio id='s2' value='2' onclick='showPreview(2)' name='star' $value><label for='s2'><img src='style_images/1/icons/2.png'></label> <br> <input type=radio id='s3' value='3' onclick='showPreview(3)' name='star' $value><label for='s3'><img src='style_images/1/icons/3.png'></label> <br> <input type=radio id='s4' value='4' onclick='showPreview(4)' name='star' $value><label for='s4'><img src='style_images/1/icons/4.png'></label> <br> <input type=radio id='s5' value='5' onclick='showPreview(5)' name='star' $value><label for='s5'><img src='style_images/1/icons/5.png'></label> Somehow I need to try to get my $value to equal 'checked' based upon my "star" variable: So I choose #5, which is <input type=radio id='s5' value='5' onclick='showPreview(5)' name='star' $value> and now my "star" value is set to 5, (I updated it through my db) how do I make $value become 'checked' when I have 4 others input type=radio's that it will check also? I only need the #5 one checked as that is one that I chose. The problem is, I have 70 of these input type Radio's and if I use $value on every one it will not show them all checked instead of just the 1 i chose I have a html/php i am creating but getting the following error:
[10-May-2019 09:42:13 UTC] PHP Fatal error: Uncaught Error: Call to a member function prepare() on null in C:\inetpub\wwwroot\SupportDesk\php\Add_New_Engineer.php:88
<?php $server = htmlentities($_SERVER['PHP_SELF']); if (isset($_POST['submit'])) { $result = create_eng(); } ?> <!DOCTYPE html> <html lang="en"> <head> <title>Add A New Engineer | DDS Dashboard</title> <meta charset="utf-8" /> <link rel="icon" type="image/png" href="../images/favicon-16x16.png"/> </head> <body> <?php include('nav.php'); include('ConnectionDB.php'); ?> <div class="jumbotron"> <div class="container"> <h1><br><img src="../images/clipboard-customer.png"/> Add New Engineer:</br></h1> </div> </div> <form class="form-horizontal" role="form" id="add_eng" action="<?php $server ?>" method = "post"> <div class="form-group"> <!--<?php //display_msg($msg);?>--> <label for="EngineerName" class="col-sm-2 control-label">Engineer Name:</label> <div class="col-sm-6"> <input type="text" class="form-control" id="EngName" name="EngineersName" placeholder="Enter Engineer's Name"></input> <small class="form-text text-muted"> Enter the new engineer's name above to enter them into the database. </small> </div> <input name="submit" type="submit" value="Create Engineer" class="btn btn-primary default"></input> <input name="reset" type="Reset" value="Reset Form" class="btn btn-primary default"></input> </div> </form> <br><br> </body> </html> <?php $sql = "Select * from [Engineers] where [Engineer] not like '%\_%' Escape '\' order by [Engineer] asc"; $stmt = $conn->prepare($sql); $stmt->execute(); $results=$stmt->fetchAll(PDO::FETCH_ASSOC); ?> <div class="containerenglist"> <div class="col-sm-5"> <table id="alleng" class="table table-bordered"> <tr> <th>Active Engineer's Names:</th> </tr> <?php foreach ($results as $row) { echo "<tr><td>"; echo $row['Engineer']; echo "</td>"; echo "</tr>"; } ?> </table> </div> </div> </body> </html> <?php Function create_eng(){ global $msgID; global $msg, $conn; include('ConnectionDB.php'); $conn = null; $msgID = 0; //Get POST from submit $eng_name = $_POST['EngineersName']; //SQL Query $sql_count = "select count(*) as num from [Engineers] where [Engineer] = :eng_name"; //Query SQL Statement //echo $eng_name; $stmt = $conn->prepare($sql_count); $stmt->bindValue(':eng_name', $eng_name); //Execute SQL Statement $stmt->execute(); $results=$stmt->fetchAll(PDO::FETCH_ASSOC); If($results['num'] > 0){ echo $msg = "Engineer $eng_name exist's in the database"; $msgID = 1; }else{ $sql_insert = "insert into [Engineers](Engineer) values '$eng_name'"; //Prepare SQL Statement $stmt = $conn->Prepare($sql_insert); //Execute SQL Statement $stmt->execute(); $results=$stmt->fetchAll(PDO::FETCH_ASSOC); echo $msg = "Engineer $eng_name added to the database"; $msgID = 2; } } ?> Everything works correctly until i try submitting a name to the DB the line that is being pulled is $stmt = $conn->prepare($sql_count);
I have an array here that looks like this: Code: [Select] Array ( [server_info] => Array ( [up] => 1 [up_since] => Sun, 23 Oct 2011 04:04:01 -0600 [up_for] => 2588 [version] => Beta 1.9 Prerelease 4 ) [players] => Array ( [0] => Pyr3x ) [server_settings] => Array ( [map] => Underworld [pvp] => 1 [pve] => 1 [max] => 50 ) [admins] => [ops] => Array ( ) ) How would I for example print the contents of the players array without having to be specific on which object within it that I wish to print, it's dynamic so it's always going to change. Example of the output I'd like is: Players: Pyr3x, SomeGuy, AnotherGuy Thank you for any help you may be able to provide. -Pyr3x EDIT: It would seem i placed this in the wrong section. Can we have a mod move this? I'm gonna go ahead and admit that this is a task that my school left me for my course in PHP and mySQL but i won't just ask for someone to construct the code for me but just to give me advice and assistance in my code. What i'm trying to do is request a number from a user and generate random integers between 1 to 100 as many as the user specified. The task told me to place all the numbers in an array and that i can use a foreach loop to go through and indicate what numbers are lower than 50 and what is higher than 50. The output should be similar to this: All your numbers: 45 23 14 79 99 22 56 Numbers lower than 50: 45 23 14 22 Numbers higher than 50: 79 99 56 This is my code: Code: [Select] <!DOCTYPE html PUBLIC "-//w3c//DTD XHTMLm 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmnlns="http://www.w3.org/1999/xhtml" xml:lang="sv" lang="sv"> <head> <meta http-equiv="Content-Type" content="text/html; charset="utf-8" /> <title>Task</title> </head> <body> <?php $Nummer=$_REQUEST['nummer']; for ($count=1;$count <= $Nummer; $count++){ $testSlump = rand(1, 100); echo $testSlump . "</br>"; } $testArray = array($testSlump); foreach ($testArray as $n) { if ($testArray > 50){ echo $testArray . echo 'this number is lesser than 50'; } } ?> </body> </html> I've googled, read through the litterature but none seem to help me. I thought to myself that one solution might be placing all values generated in a for loop in an array and then using the foreach loop to confirm what is what. Class notes and our schools PHP help site doesnt have anything that would help me finish this task. How do you place for loop values in an array? (if i'm on the right track) Any help etc is greatly appreciated. Hello all, I wrote a script that will upload an avatar to a users profile and to do this the user has to get a randomly generated pin that is stored to thier profile info in a MySQL db what i am trying to accomplish with this code is once the form is submitted this code checks the database to see if the ID is there and that the pin matches if so then it continues to upload the file if not it stops displays an error and the upload form. For some reason the script continues to upload even when i input fake values that are not in the DB .... i know its something simple that im jsut over looking so perhaps a fresh set of eyes will help... <?php include './config.php'; include './access.php'; // Receiving variables @$steamid = addslashes($_POST['steamid']); @$pin = addslashes($_POST['pin']); @$avatar_Name1 = $_FILES['avatar']['name']; @$avatar_Size = $_FILES['avatar']['size']; @$avatar_Temp = $_FILES['avatar']['tmp_name']; @$avatar_Mime_Type = $_FILES['avatar']['type']; @$ava_strQuery1 = "SELECT * FROM $member_table WHERE authid='$steamid' AND private_pin='$pin'"; @$ava_host1 = "$hostname"; @$ava_user1 = "$username"; @$ava_pw1 = "$password"; @$ava_db1 = "$database"; $ava_link1 = mysql_connect($ava_host1, $ava_user1, $ava_pw1); if (!$ava_link1) { die('Could not connect: ' . mysql_error()); } $ava_db_selected1 = mysql_select_db($ava_db1, $ava_link1); if (!$ava_db_selected1) { die ('Can not use $ava_db1 : ' . mysql_error()); } //upload file and insert new record if ID and PIN match $ava_result1 = mysql_query($ava_strQuery1); if (!$ava_result1) { function findexts ($avatar_Name1) { $filename = strtolower($avatar_Name1) ; $exts = split("[/\\.]", $avatar_Name1) ; $n = count($exts)-1; $exts = $exts[$n]; return $exts; } $ext = findexts ($_FILES['avatar']['name']) ; $ran = rand () ; $ran2 = $ran."."; $avatar_Name = $ran2.$ext; //Checking/Making Folder function RecursiveMkdir($path) { if (!file_exists($path)) { RecursiveMkdir(dirname($path)); mkdir($path, 0777); } } // Validation if (strlen($steamid) <15) { die("<p align='center'><font face='Arial' size='3' color='#66CCFF'>Please enter a valid steamid <br>(ex: STEAM_0:0:00000)</font></p><p align='center'><a href='avatar.php'>BACK</a></p>"); } if (strlen($steamid) >20) { die("<p align='center'><font face='Arial' size='3' color='#66CCFF'>Please enter a valid steamid <br>(ex: STEAM_0:0:00000)</font></p><p align='center'><a href='avatar.php'>BACK</a></p>"); } if (strlen($steamid) == 0 ) { die("<p align='center'><font face='Arial' size='3' color='#66CCFF'>Please enter a valid steamid <br>(ex: STEAM_0:0:00000)</font></p><p align='center'><a href='avatar.php'>BACK</a></p>"); } if (strlen($pin) !=12) { die("<p align='center'><font face='Arial' size='3' color='#66CCFF'>Please enter a valid pin<br>Dont have a pin? click <a href='#'>here</a></font></p><p align='center'><a href='avatar.php'>BACK</a></p>"); } if (strlen($pin) == 0 ) { die("<p align='center'><font face='Arial' size='3' color='#66CCFF'>Please enter a valid pin<br>Dont have a pin? click <a href='#'>here</a></font></p><p align='center'><a href='avatar.php'>BACK</a></p>"); } if( $avatar_Size == 0) { die("<p align='center'><font face='Arial' size='3' color='#66CCFF'>Please select an image that is 50KB or less in size and its type is .jpg, .gif, or .png</font></p><p align='center'><a href='avatar_upload.php'>BACK</a></p>"); } if( $avatar_Size >51200) { //delete file unlink($avatar_Temp); die("<p align='center'><font face='Arial' size='3' color='#66CCFF'>Please select an image that is 50KB or less in size and its type is .jpg, .gif, or .png</font></p><p align='center'><a href='avatar_upload.php'>BACK</a></p>"); } if( $avatar_Mime_Type != "image/gif" AND $avatar_Mime_Type != "image/jpeg" AND $avatar_Mime_Type != "image/pjpeg" AND $avatar_Mime_Type != "image/png" AND $avatar_Mime_Type != "image/x-png") { unlink($avatar_Temp); die("<p align='center'><font face='Arial' size='3' color='#66CCFF'>Please select an image that is 50KB or less in size and its type is .jpg, .gif, or .png</font></p><p align='center'><a href='avatar_upload.php'>BACK</a></p>"); } $uploadFile = "avatars/".$avatar_Name ; if (!is_dir(dirname($uploadFile))) { @RecursiveMkdir(dirname($uploadFile)); } else { @chmod(dirname($uploadFile), 0777); } @move_uploaded_file( $avatar_Temp , $uploadFile); chmod($uploadFile, 0644); $avatar_URL = "*************/".$avatar_Name ; //saving record to MySQL database @$ava_strQuery = "UPDATE $member_table SET avatar ='$avatar_Name' WHERE authid='$steamid' AND private_pin='$pin'"; @$ava_host = "$hostname"; @$ava_user = "$username"; @$ava_pw = "$password"; @$ava_db = "$database"; $ava_link = mysql_connect($ava_host, $ava_user, $ava_pw); if (!$ava_link) { die('Could not connect: ' . mysql_error()); } $ava_db_selected = mysql_select_db($ava_db, $ava_link); if (!$ava_db_selected) { die ('Can not use $ava_db : ' . mysql_error()); } //insert new record $ava_result = mysql_query($ava_strQuery); if (!$ava_result) { die('Invalid query: ' . mysql_error()); } mysql_close($ava_link); echo("<p align='center'><font face='Arial' size='3' color='#66CCFF'>Image uploaded OK!</font></p><p align='center'></p>"); echo "<div align='center'>"; echo "<p><img src=$avatar_URL></p>"; include ('./includes/avatar_upload.php'); echo "</div>"; }else{ //if ID and PIN dont match display error and form echo "Wrong SteamID/Pin Please Try Again..."; echo "<br />"; include ('./includes/avatar_upload.php'); } mysql_close($ava_link1); ?> Alright, so I've been building code in my computer science class (no prior PHP experience before approx. this past week). We're just importing the first array from a MySQL database, and it's not working for me. Our teacher included a broken-linked image that apparently tells us how to close the connection, but being unable to see it....I can't. I'm not sure exactly what's not working, but here's my current code: Code: [Select] <html> <body> <?php echo "<h1>This is a test. Does this script insert values?</h1>"; // Connect to the database $dbc = mysqli_connect('localhost', 'root', 'root', 'myrent-a-movie-final') or die('Error connecting to MySQL server.'); // Build the query $query = "SELECT * FROM customers"; $result = mysqli_query($dbc, $query) or die('Error querying database.'); //Display Results through Array Loop While ($row = mysqli_fetch_array($result)) { echo $row['surname']; echo $row['given_name']; echo $row['address']; echo $row['city']; echo $row['province']; echo $row['postal_code']; echo $row['phone_number']; echo $row['email']; // Close the database connection mysqli_close($dbc); ?> </body> </html> And here is my accompanying error message: "Parse error: syntax error, unexpected $end in Z:\www\mysql_basics\view_data.php on line 32" Hey all, I'm currently working on a website/database system. What i'm trying to achieve atm is for a user to be able to edit current data in a database table, submit it, and for it to display the new data in the webpage. The table i'm reading from has 6 records and the fields ID(which is just auto_incremented) and courseName. Ideally, I would like the user to be able to delete a record too. The code I have written displays the courseName's in a table along with textareas and a submit button for each row. It seems to be doing nothing at the minute, so I was hoping someone could enlighten me as to what I've done wrong and if someone could provide what code i'm missing if any, i would be ever so grateful I think I might have structured it all wrong, I hope this isn't the case! My current code is below, hope to hear some feedback soon, many thanks, Aaron PS: feel free to ask any more question in case I've forgot to mention something Code: [Select] <?php session_start(); $hostname_logon = "***.*.*.*" ; $database_logon = "aal9" ; $username_logon = "root" ; $password_logon = "" ; $coursenametext = ''; $id = ''; //error_reporting (E_ALL ^ E_NOTICE); $connections = mysql_connect($hostname_logon, $username_logon, $password_logon) or die ( "Unable to connect to the database" ); mysql_select_db($database_logon) or die ( "Unable to select database!" ); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Edit Courses</title> <link href="Aaron.css" rel="stylesheet" type="text/css" /> </head> <div class="container"> <h1><img src="logo.gif" alt="Logo" width="224" height="62" id="logo" align="left"/></a>Update Courses</h1> </div> <div class="sidebar1"> <ul class="nav"> <li><a href="homepage.php">Homepage</a></li> <li><a href="modules.php">My Modules</a></li> <li><a href="update.php">Update Database</a></li> <li><a href="googles1.php">Sem 1 Google</a></li> <li><a href="timetable2.php">Sem 2 Timetable</a></li> <li><a href="googles2.php">Sem 2 Google</a></li> <li><a href="logout.php">Logout</a></li> </ul> <p><a href="javascript:window.print()">Print This Page</a></p> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. </p> <p>Welcome To Timetable Management. Please Find All Necessary Links Above.</p> </div> <div class="content"> <form action="editcourses.php" method="post"> <table border="1" cellspacing="1" align="center" bordercolor="#FFFFFF"> <tr> <td>Course Name</td> <td>Edit</td> <td>Submit</td> <td>Delete</td> </tr> <?php $query = "SELECT * FROM Courses "; $result = mysql_query ($query); if(mysql_num_rows($result)>0){ while($row = mysql_fetch_array($result)) { echo('<tr>' . '<td>' . $row['CourseName'] . '</td>' . '<td><input type="hidden" name="id" value="' . $row['ID'] . '"/><textarea name="coursenametext" rows="2"></textarea>' . '</td>' . '<td>' . '<input type="Submit" name="Submit" value="Submit">' . '</td>' . '</tr>'); } } if(isset($_POST['Submit'])) { $query1 = "UPDATE courses SET courseName = '".$_POST['coursenametext']."' WHERE ID = '".$_POST['id']."'"; $result1 = mysql_query ($query1); } ?> </table> </form> <br> </div> <div class="footer"> <p><a href="mailto:***@**.**.**" class="Email">Click Here To Email For Help With Faults</a></p> </div> </div> </body> </html> So I have the following and for some reason or another it's not wanting to work with me. If I do the query directly in phpmyadmin it will return the number, however for some reason when I throw it into a variable it won't return anything. I have a feeling it's because of the text string? How do you properly represent a string of text that has a space between it? 1st query get's the name from another table: $query = "SELECT name FROM info WHERE userdid = 4"; $data = mysqli_query($dbc, $query); $row = mysqli_fetch_array($data); $tname = $row['name']; Table: testing rows: number name data: 4 Testing This $query1 = "SELECT number FROM testing WHERE name = '" . $tname . "'"; $data1 = mysqli_query($dbc, $query1); $row1 = mysqli_query($data1); $numreturn = $row1['number']; // Do stuff Hows it going guys. Well, I'm trying to create an app tat deals with the barracuda API. Unfortunately it uses all XML for its methods, so I had to come up with this: Code: [Select] <?php include ("xmlrpc.inc"); $y = new xmlrpcval ( array ("child_type" => new xmlrpcval("domain", "string"), "path" => new xmlrpcval("", "string"),"type" => new xmlrpcval("global", "string")) , "struct"); $m = new xmlrpcmsg ('config.list'); $m ->addParam($y); $c= new xmlrpc_client("http://barracudaaddress/cgi-mod/index.cgi?password=mypassword"); $c->setDebug(2); $r = $c ->send($m); if (!$r->faultcode()) { $v= $r->value(); print $r->serialize(); } else { print "Fault <br/>"; print "Code: ". htmlentities($r->faultcode()) . "<br/>" . "reason: '" . htmlentities($r->faultString()) . "'<br/>"; } ?> the problem is that when I run this, i get the following error: Code: [Select] XML error: XML_ERR_NAME_REQUIRED at line 2, column 61Fault Code: 2 reason: 'Invalid return payload: enable debugging to examine incoming payload (XML error: XML_ERR_NAME_REQUIRED at line 2, column 61)' but when i look at my php code, line 2 is technically: Code: [Select] include ("xmlrpc.inc"); Does this mean my error is coming from that file? Because as far as I can tell, the XML output is working well, since this is what is getting sent to the server: Code: [Select] <?xml version="1.0"?> <methodCall> <methodName>config.list</methodName> <params> <param> <value><struct> <member><name>child_type</name> <value><string>domain</string></value> </member> <member><name>path</name> <value><string></string></value> </member> <member><name>type</name> <value><string>global</string></value> </member> </struct></value> </param> </params> </methodCall> Which is what is required for this method. I've racked my brain and can't figure it out, any help would be appreciated. This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=348975.0 Hi, I am trying to figure out how to stop my script from offering a discount when the date that is listed passes by. It seems to always 'reset' itself even after the 15th of the month...I want it to stop after April 15...This is what I had, can anyone assist? Thank you in advance for your help! Jennifer Code: [Select] } if(date("n") < 15) { $before = $cost*.05; $before = round($before,2); $cost = $cost-$before; } |