PHP - Variable Not Changing For Dns Update Command
I am trying to get a simple thing working. I have a domain with google that I want to change the point to IP when I access a PHP page. I have a DB table with settings that I am using for the username, password, etc. The issue is that the command to change the IP always sends the same IP. No matter what I try. I have tried assigning a fixed entry for the variable $localip, I have set that variable to 0 ahead of the query to get the info from the table. Nothing I do will change the variable in the command. I can manually put the command in a browser and it will perform the change. Can anyone comment on what I am missing here?
<?php ini_set("display_errors", 1); ini_set("track_errors", 1); ini_set("html_errors", 1); error_reporting(E_ALL); require('/var/www/html/cqadmin/utils/connect.php'); $sql = "SELECT * FROM `failover` LIMIT 0, 30"; $result = mysqli_query($link,$sql) or die(mysql_error()); $row = mysqli_fetch_array($result); $localip = ($row['localip']); $dnsusername = ($row['dnsusername']); $dnspassword = ($row['dnspassword']); $domain = ($row['failoverurl']); $location = ($row['location']); $dealer = ($row['dealer']); $output = shell_exec("curl -s https://$dnsusername:$dnspassword@domains.google.com/nic/update?hostname=$domain&myip=$localip"); mysqli_close($link); ?> I get no errors on the page and if I echo $output I get a nochng message back from Google
Thanks for looking!! Similar TutorialsHi all, I need to create a button my page that when clicked will update my mysql table. I also need a command that will find 3 'x' values and update them accordingly, It needs to update the theme column in my model pictures table, Would something similiar like this work? Code: [Select] UPDATE theme SET name = '5' WHERE name = '1 or 2 or 4';[code] Does this make sense? Hello people, At the moment I am really desperate. I've done this script over 20 times now, always with the same script but all of a suddon, it doesn't work anymore. heres the problem: I made a very simple "patient database" for a doctor. Where he can upload patients, alter and delete them. The script to add the patients works fine. now im trying to make a script where he can alter the variables agian, using the UPDATE command. but instead of updating the variables it cleares all the date in the row. can someone help me? here s the entire code: Code: [Select] <?PHP include'connect.php'; ?> <?PHP $SQL = mysql_query("SELECT * FROM leys_patienten WHERE patientid='".$_REQUEST['patientid']."'"); while ($row = mysql_fetch_array($SQL)) { ?> <?PHP if ($_POST[submit]) { if (!$_POST[volgnummer]) { echo "<font size=\"2\" color=\"#990000\"><b>--> Vul een volgnummer in a.u.b. <--</b></font>"; } elseif (!$_POST[naam]) { echo "<font size=\"2\" color=\"#990000\"><b>--> Vul een naam in a.u.b. <--</b></font>"; } elseif (!$_POST[voornaam]) { echo "<font size=\"2\" color=\"#990000\"><b>--> Vul een voornaam in a.u.b.! <--</b></font>"; } else { mysql_query("UPDATE leys_patienten SET volgnummer='$volgnummer',naam='$naam',voornaam='$voornaam',adres='$adres',postcode='$postcode',plaats='$plaats',telefoon='$telefoon',email='$email',geboortedatum='$geboortedatum',geboorteplaats='$geboorteplaats',opmerkingen='$opmerkingen' WHERE patientid='".$_REQUEST['patientid']."'") or die(mysql_error()); echo "Het patientendossier is succesvol gewijzigd, let op doorschakeling.";?> <meta http-equiv="Refresh" content="1; url=patient.php?patientid=<?PHP echo $row['patientid']?>" /> <? } } ?></p> <form action="<?$PHP_SELF?>" method="post" name="post" id="post"> <table width="805" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td class="table_forms">Volgnummer*</td> <td class="table_forms"><label><input name="volgnummer" type="text" id="volgnummer" value="<?PHP echo $row['volgnummer']?>" size="40" /></label></td> </tr> <tr> <td width="146" class="table_forms">Naam*</td> <td width="659" class="table_forms"><label><input name="naam" type="text" id="naam" value="<?PHP echo $row['naam']?>" size="40" /></label></td> </tr> <tr> <td class="table_forms">Voornaam*</td> <td class="table_forms"><font color="#FFFFFF" size="2"> <label><input name="voornaam" type="text" id="voornaam" value="<?PHP echo $row['voornaam']?>" size="40" /></label> </font></td> </tr> <tr> <td class="table_forms">Adres </td> <td><font color="#FFFFFF" size="2"> <label><input name="adres" type="text" id="adres" value="<?PHP echo $row['adres']?>" size="40" /></label> </font></td> </tr> <tr> <td class="table_forms">Postcode</td> <td><font color="#FFFFFF" size="2"> <label><input name="postcode" type="text" id="postcode" value="<?PHP echo $row['postcode']?>" size="6" /></label> </font></td> </tr> <tr> <td class="table_forms">Plaats</td> <td><font color="#FFFFFF" size="2"> <label><input name="plaats" type="text" id="plaats" value="<?PHP echo $row['plaats']?>" size="40" /></label> </font></td> </tr> <tr> <td class="table_forms">Telefoon</td> <td><font color="#FFFFFF" size="2"> <label><input name="telefoon" type="text" id="telefoon" value="<?PHP echo $row['telefoon']?>" size="40" /></label> </font></td> </tr> <tr> <td class="table_forms">E-mail</td> <td><font color="#FFFFFF" size="2"> <label><input name="email" type="text" id="email" value="<?PHP echo $row['email']?>" size="40" /></label> </font></td> </tr> <tr> <td class="table_forms">Geboortedatum</td> <td><font color="#FFFFFF" size="2"> <label><input name="geboortedatum" type="text" id="geboortedatum" value="<?PHP echo $row['geboortedatum']?>" size="40" /></label> </font></td> </tr> <tr> <td class="table_forms">Geboorteplaats</td> <td><font color="#FFFFFF" size="2"> <label><input name="geboorteplaats" type="text" id="geboorteplaats" value="<?PHP echo $row['geboorteplaats']?>" size="40" /></label> </font></td> </tr> <tr> <td valign="top" class="table_forms">Opmerkingen</td> <td><font color="#FFFFFF" size="2"> <label><textarea name="opmerkingen" cols="40" rows="4" id="opmerkingen"><?PHP echo $row['opmerkingen']?></textarea></label> </font></td> </tr> <tr> <td valign="top" class="table_forms"> </td> <td><span class="body_tekst"> <input type="submit" id="submit" name="submit" value="verstuur" /> </span></td> </tr> </table> <p class="body_tekst"> </p> </form> <? } ?> This is the weirdest thing ever. I've been programming php for years yet I have been pulling my hair out for hours over something that seems so simple! I have a table in my db named last_num_used with 2 fields: id, num which are both type int. It only has one row, so I don't need to use WHERE to update when I execute the command via php: Code: [Select] $sql = "UPDATE last_num SET num='4'"; echo $sql; if (!mysql_query($sql)) {die('Error: ' . mysql_error());}everything works fine and I see the echoed command UPDATE last_num SET num='4' But, when I have a variable $var and try to update it, it will only update properly if $var=1 or $var=2. If $var equals a value greater than 2, then for some reason it updates the column so that num=1. Note the exact problem in example 3 below. Example 1: Code: [Select] $var=1; $sql = "UPDATE last_num SET num='$var'"; echo $sql; if (!mysql_query($sql)) {die('Error: ' . mysql_error());}Result: echoed to screen: UPDATE last_num SET num='1' database updated and num=1 Example 2: Code: [Select] $var=2; $sql = "UPDATE last_num SET num='$var'"; echo $sql; if (!mysql_query($sql)) {die('Error: ' . mysql_error());}Result: echoed to screen: UPDATE last_num SET num='2' database updated and num=2 Example 3: Code: [Select] $var=3; $sql = "UPDATE last_num SET num='$var'"; echo $sql; if (!mysql_query($sql)) {die('Error: ' . mysql_error());}Result: echoed to screen: UPDATE last_num SET num='3' database updated and num=1 I am a bit rusty with mySQL and I tried to borrow some other query code and modify it into an update command...apparently I am trying to use an invalid property in my error checking. Basically I just want to check and see if there were NO rows updated so I can let the user no that nothing was changed. There are probably easier ways to do this? The page where I set the variable values is based on a form post. I am not sure how to write my validation tests. Right now it is running the update successfully but it is reporting back an error based on hitting the "else if" test where I am trying to see if no rows were updated. The error message is: Quote Encountered error: 8 in /home/omgma/public_html/member_community/mbr_profiles/mbr_profile_updt_post.php, line 85: Trying to get property of non-object No fields were updated! Error: 0 Code: [Select] //create a SQL statement $updt_cmd = "UPDATE users t1, directory t2 " ."SET t1.email = '$email', " ."t2.first_name='$first_name', " ."t2.last_name='$last_name', " ."t2.suffix='$suffix', " ."t2.website_url='$website_url' " ."WHERE t1.username ='$username' AND t2.directory_id = t1.directory_id"; $conn = db_connect(); $result = $conn->query($updt_cmd); if (!$result) {//could not execute query throw new Exception('<h2>Could not execute member profile update!</h2><p>Error: ' .mysqli_errno($conn) .mysqli_error($conn) .'</p>' ); } else if ($result->num_rows==0) {// no rows so nothing was updated. throw new Exception('<h2>No fields were updated! </h2><p>Error: ' .mysqli_errno($conn) .mysqli_error($conn) .'</p>' ); } else { $mbr_profile = $result->fetch_object(); print_r($mbr_profile); return $mbr_profile; } Am I using the right functions here to do this and if so where can I find the class properties to use to test if nothing was updated? Thanks I typically only use the first two solutions. Is there anything wrong with the third? Is there any more streamlined way to do it?
function f1($x){return $x*1;} function f2($x){return $x*1;} $x=2;$y=1; if(f1($x)>f2($y)){echo(f2($y)."\n");} // or $f2_y=f2($y); if(f1($x)>$f2_y){echo($f2_y."\n");} // or if(f1($x)>$f2_y=f2($y)){echo($f2_y."\n");} Hi i dont know whether i've overlooked something but im finding it hard to answer this myself.. Background of the problem: Im keeping the contents of a page in a database, so each page would be a template, and the body text will be stored in the database. So if i want to call up the contents for my 'About' page, i would use the php command: "<?php getAboutPosts(); ?>" The code behind that will be: function getAboutPosts() { $query = mysql_query("SELECT * FROM posts WHERE id = '20' ") or die (mysql_error()); while($subm = mysql_fetch_assoc($query)) { echo "<h2>" . $subm['Title'] . " by iVisual Media" . "</h2>"; echo $subm['Content']; } } My Actual Problem The text does echo fine, but it is completely unstructured, I.E. it isn't paragraphed, i cant include any type of tag like <b> because it doesn't seem to echo them, although when i check PHPMyAdmin it has all the tags saved in with the content? Example: I have this saved in MySQL Database: <h4>We are a professional website and graphic design business in Basildon, Essex, providing online marketing strategies for companies throughout the UK.</h4> <p><br /> Whether you require a brochure website, blog or a full e-commerce solution, Imagine Design Studio can help. Maybe you have a new business and want to create an online presence or an established business looking to pull your company into the 21st century.</p> <p> But when it echos, i get this: We are a professional website and graphic design business in Basildon, Essex, providing online marketing strategies for companies throughout the UK. Whether you require a brochure website, blog or a full e-commerce solution, Imagine Design Studio can help. Maybe you have a new business and want to create an online presence or an established business looking to pull your company into the 21st century. Things i've tried: Adding a class to the DIV which the echo will go into - This works for colouring etc, but i still need to paragraph the text and use italics occasionally. Please help guys! Thanks in advance quick question i have located in my code
$r = mysql_query("insert into points values ('${v[0]}', ${v[1]}, '$At') on duplicate key update Points = Points + ${v[1]}");-it is updateing the player points but i need it to do a new entry how would i go about that i tried just taking out the on duplicate and it gives me a tstring insert error on next line. if i leave it in i get no error Hi, I have a weather app, coded which creates weather based on a set zip code. I want to create a form which when the user fills out their local code and clicks the send button that will change the zip code variable. Currently it is set up like this $zip = '90210'; //change to your zipcode need help with getting started with this. Thanks! if ($rowcats->followersrange == "2000-5000") { $lowrange2000 = "2000"; $lowestrange = $lowrange2000; $numberpeople = $rowcats->numberpeople; } if ($rowcats->followersrange == "5000-10000") { $lowrange5000 = "5000"; if ($lowrange5000 < $lowestrange) { $lowestrange = $lowrange5000; $numberpeople = $rowcats->numberpeople;} } if ($rowcats->followersrange == "10000-15000") { $lowrange10000 = "10000"; if ($lowrange10000 < $lowestrange) { $lowestrange = "$lowrange10000"; $numberpeople = $rowcats->numberpeople;} if ($lowestrange == NULL) { echo "yes";} echo "$lowestrange"; } if ($rowcats->followersrange == "15000-20000") { $lowrange15000 = "15000"; if ($lowrange15000 < $lowestrange) { $lowestrange = $lowrange15000;$numberpeople = $rowcats->numberpeople;} } We are trying to find the lowest range from the entries added to a database, so at the end, we can say the range is FROM... TO... They might opt for 2-5k, or 5-10k etc. If they opt for 10-15k, then the lowest range is 10,000. We have a result of 10000 - 15000. So the $lowrange10000 = "10000". Therefore, this should be echoing the $lowestrange from 7th line up in this code, but it remains at NULL, based on: $lowestrange = NULL;, set at the top of the code. Why is that? Usually it would be something like:
$("#lblpasswordmessage").html("Password is too short");But how do you do it using a variable? For example say the variable is called 'pwm'; $("#pwm").html("Password is too short"); $("pwm").html("Password is too short"); $(pwm).html("Password is too short");Thanks Hello everyone, I'm having a difficult time figuring out what my problem is here. I'm trying to submit a couple of strings (to the user they are messages to be sent to other users) and I am having trouble with the string being cut off at quotation marks. Here is the code that I'm using: Code: [Select] <?php if (isset($_POST['submit'])) { $staffmessage = $_POST['staffmessage']; $studentmessage = $_POST['studentmessage']; echo "$staffmessage<br /> <br />$studentmessage"; } ?> <!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=iso-8859-1" /> </head> <body> <?php $message1="This is a test message. It does not get cut off here when the \"quotation marks\" are added."; $message2="This is a test message. It DOES get cut off here when the \"quotation marks\" are added."; ?> <form name="form" method="post" action="test.php"> <textarea class="textarea" name="staffmessage" rows="12"> <?php echo $message1; ?> </textarea></p> <input name="studentmessage" type="hidden" value="<?php echo $message2; ?>" /> <input class="submit2" type="submit" name="submit" value="Send Message" /> </form> </body> </html> The result that I'm getting is that when $staffmessage is echoed, I get the full message. When $studentmessage is echoed, the message gets cut off at the first quotation mark. The only thing that is different when creating these two variables is that $staffmessage is submitted using a "textarea" field in the form, and $studentmessage is submitted using a "hidden" field in the form. Other than that, they are handled the exact same way. Can anyone please help me figure out how to remedy this so that $studentmessage is not cut off at the quotation mark? Thanks in advance for your help! Hi, I have been on and off this forum loads of time and it has helped me out so much over the past few months with different projects. But today there is one thing i simply cant figure out or find any kind of answer anywhere and would be really grateful if someone could give me a pointer. I have a form which which i use to input data into a mysql database. One of the variables Code: [Select] $budget=$_POST['budget']; which I use to add data to the 'budget' field in my database. In the form, budget is a dropdown with a few options: Code: [Select] <select name="budget" id="budget"> <option selected="selected">Please Choose One</option> <option>up to 500 Euros</option> <option>500 to 1000 Euros</option> <option>1000 to 1500 Euros</option> <option>1500 to 3000 Euros</option> <option>3000 to 5000 Euros</option> <option>Over 5000</option> <option>No Budget Set Yet</option> </select> I have another field in my database called 'price'. What I would like to do is, if someone chooses a budget of 3000 to 5000 I would like this to enter 5.00 in the price field in the database. I have tried a number of things, but nothing is working for me. This is where I am at now, which doesn't work either but thought it might give a better explanation of what I am trying to achieve. Code: [Select] $budget=$_POST['budget']; $price=$budget['up to 500 Euros']='3.50'; $price=$budget['500 to 1000 Euros']='5.00'; $price=$budget['1000 to 1500 Euros']='4.50'; $price=$budget['1500 to 3000 Euros']='5.00'; $price=$budget['3000 to 5000 Euros']='5.50'; $price=$budget['Over 5000']='6.00'; $price=$budget['No Budget Set Yet']='4.00'; Also keep in mind that there is no 'price' field in the form. So no price is being posted to the processing page. I need to price to be worked out by what is posted from the budget field. This is the only thing I am stuck with without having to ask for any help, and these forums have been a saviour to me and an excellent place for learning. But sometimes I think you have to give in and just ask for help! lol Many thanks, DB Hi This does not make sense to me, I hope someone can tell me why this query don't work: Code: [Select] safe_query("UPDATE ".PREFIX."cup_challenges SET reply_date='$postdate', $select_map $select_date challenged_info='".$_POST['info']."', status='2' WHERE chalID='".$_GET['challID']."'");; and this query does work: Code: [Select] safe_query("UPDATE ".PREFIX."cup_challenges SET reply_date='$postdate', map1='".$_POST['map1']."', map2='".$_POST['map2']."', map3='".$_POST['map3']."', date1='".$_POST['date1']."', date2='".$_POST['date2']."', date3='".$_POST['date3']."', date4='".$_POST['date4']."', challenged_info='".$_POST['info']."', status='2' WHERE chalID='".$_GET['challID']."'"); Variables in $select_map and $select_date makes the query fail but when I copy/paste this (bold) in query it works: $select_map = map1='".$_POST['map1']."', map2='".$_POST['map2']."', map3='".$_POST['map3']."', $select date = date1='".$_POST['date1']."', date2='".$_POST['date2']."', date3='".$_POST['date3']."', date4='".$_POST['date4']."', am I using the variable in query incorrectly? im trying to make a breadcrumbs feature on my site. this feature is driven using the session variables. My problem here is that.. i just wondering what make the session variables display its own value (not expected value).. this variable name got no similar across the whole site. i just wanna hear what are the possible causes why this happen... thanks How can I make my on change in the form pass through the year thats been selected, then use that in the second query? Code: [Select] <select name="mySelect" onchange=""> <?php $result= mysql_query('SELECT DISTINCT Year FROM MonthlySales'); ?> <?php while($row= mysql_fetch_assoc($result)) { ?> <option value="<?php echo htmlspecialchars($row['Year']);?>"> <?php echo htmlspecialchars($row['Year']); ?> </option> <?php } ?> </select> <?php $query="SELECT * FROM MonthlySales WHERE Year = PASS YEAR SELECTED VARIABLE TO THIS BIT HERE"; $results = mysql_query ( $query, $conn); Please take a look at the following code (this would work if the statement was SELECT instead of UPDATE) But I need to grab the following: Code: [Select] $result = mysql_query("UPDATE `AUCTIONS_MAIN` SET Current_Price = Current_Price + '$increase_price', Last_Bidder_Time = '$last_bidder_time' WHERE PId = '$id'"); //grab the new updated current price to save on different bidding history DB while($row=mysql_fetch_array($result)) { $current_price = $row['Current_Price']; } As you can see, I need to give the new Current_Price value to the $current_price variable. Obviously the while function is incorrect, I would really appreciate any ideas and/or suggestions on how I can grab this value. PS: I can't make a new query call with a select statement in order to know the new Current_Price. I need the direct updated value coming from the Update Statement, is this possible? Thanks a lot in advance!! Hi there, is it possible to join a variable and a string inside a $_POST variable inside a mysql query (UPDATE in this case) Here is what i am trying to accomplish: $update = "UPDATE mona SET STKFF='$_POST[$counter."NAME"]' WHERE id='$userid'"; if (!mysql_query($update)) { die('Error: ' . mysql_error()); } else echo " <br> Update Complete"; Its the '$_POST[$counter."NAME"]' bit that im worried about, is this possible without having to do: $foo=$counter."NAME" '$_POST[$foo]' Thanks Chris This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=321230.0 I am facing problem to execute query by assigning NULL value to a variable and then executing query.In MySQL DB four fields Mobile,landline, pincode,dob are set as integer and date(for dob) respectively.The default is set as NULL and NULL option is selected as yes.All these fields are not mandatory.The problem is that when I edit the form my keeping the value as empty in DB these are saved as 0, 0 , 0 & 0000-00-00 inspite of Null. I have tried everything but still the defect persist. Please help me to come out of the problem The code, I have used: <?php //require_once 'includes/config.php'; $dbusername = $_POST['email']; $dbfirstname = $_POST['first_name']; $dblastname = $_POST['last_name']; //$dbmobile_number = $_POST['mobile']; if (isset($_POST['mobile'])) { $dbmobile_number = $_POST['mobile']; } else { $dbmobile_number = "NULL"; } $dblandline_number = $_POST['landline']; $dbdob = $_POST['dob']; if(isset($_POST['is_email'])) { $dbSubscribe_Email_Alert = '1'; } else { $dbSubscribe_Email_Alert = '0'; } if(isset($_POST['is_sms'])) { $dbSubscribe_SMS = 0; } else { $dbSubscribe_SMS = 0; } $dbAddress_firstname = $_POST['shipping_first_name']; $dbAddress_lastname = $_POST['shipping_last_name']; $dbAddress = $_POST['shipping_address']; $dbcity = $_POST['shipping_city']; $dbpincode = $_POST['shipping_pincode']; $dbstate = $_POST['shipping_state']; $dbcountry = $_POST['shipping_country']; echo "Welcome".$dbusername; //if($_POST['btnSave']) //if ($_POST['btnSave']) //{ //echo "Inside query loop"; $connect = mysql_connect("localhost","root","") or die("Couldn't connect!"); mysql_select_db("salebees") or die ("Couldn't find DB"); //$query = mysql_query("SELECT * FROM users WHERE username='$username'"); $query = mysql_query("update users set firstname = '$dbfirstname', lastname = '$dblastname', mobile_number = '$dbmobile_number', landline_number = '$dblandline_number', dob = '$dbdob', Subscribe_Email_Alert = '$dbSubscribe_Email_Alert', Subscribe_SMS = '$dbSubscribe_SMS', Address_firstname = '$dbAddress_firstname', Address_lastname = '$dbAddress_lastname', Address = '$dbAddress', city = '$dbcity', pincode = '$dbpincode', state = '$dbstate', country = '$dbcountry' where username = '$dbusername' "); header("location:my_account.php"); //} //else //{ //die(); //} ?> Can anyone post a generic update function to update mysql table. The manual approach: update $tablename set $column1='a', $column2='b' where $id=$value; |