Jump to content

john.muckley

Members
  • Posts

    16
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

john.muckley's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks barand! I implemented this like so... <?php $types = simplexml_load_file("data.xml"); $xml = simplexml_load_string($types); foreach ($xml->listcapacityresponse->capacity as $cap) { $results[] = (array)$cap; } echo '<pre>',print_r($results, true),'</pre>'; ?> ...but it doesnt seem to be working. I get no output at all, any idea where i'm going wrong? Thanks!
  2. Hey guys, Hoping someone can help me out. I have this XML output from a cloud management API which looks like this: <listcapacityresponse cloud-stack-version="4.2.1"><count>6</count> <capacity> <type>8</type><zoneid>f26c2094-f2ca-4951-9265-a3f036e7f045</zoneid><zonename>DBXCP1</zonename><capacityused>6</capacityused><capacitytotal>18</capacitytotal><percentused>33.33</percentused> </capacity> <capacity> <type>0</type><zoneid>f26c2094-f2ca-4951-9265-a3f036e7f045</zoneid><zonename>DBXCP1</zonename><capacityused>27246198784</capacityused><capacitytotal>97078222080</capacitytotal><percentused>28.07</percentused> </capacity> <capacity> <type>1</type><zoneid>f26c2094-f2ca-4951-9265-a3f036e7f045</zoneid><zonename>DBXCP1</zonename><capacityused>13500</capacityused><capacitytotal>52800</capacitytotal><percentused>25.57</percentused> </capacity> <capacity> <type>5</type><zoneid>f26c2094-f2ca-4951-9265-a3f036e7f045</zoneid><zonename>DBXCP1</zonename><capacityused>3</capacityused><capacitytotal>12</capacitytotal><percentused>25</percentused> </capacity> <capacity> <type>6</type><zoneid>f26c2094-f2ca-4951-9265-a3f036e7f045</zoneid><zonename>DBXCP1</zonename><capacityused>14619246592</capacityused><capacitytotal>106308304896</capacitytotal><percentused>13.75</percentused> </capacity> <capacity> <type>3</type><zoneid>f26c2094-f2ca-4951-9265-a3f036e7f045</zoneid><zonename>DBXCP1</zonename><capacityused>92190801920</capacityused><capacitytotal>1099511627776</capacitytotal><percentused>8.38</percentused> </capacity> </listcapacityresponse> Each 'type' represents a different available resource, so like type 1 is available CPU, type 0 is available RAM. That sort of thing. I need to be able to parse this so i can split up the individual resources and eventually display their data as a chart. I can do the chart bit, but i need to split the data up first. Any help is appriciated. Thanks Jonny
  3. Haha!!! that was exactly it! thanks cyberRobot!
  4. Hey guys, so i've got a create user form which allows new users to be created and added into the database as valid users for my site. as part of this form, you can select an access level, ie admin, manager, user. For some reason, no matter what i put here, the new user is always added as level 3 - which is user. I've read and reread the code and cannot see for the life of me why it is doing this! Can anyone help? Here is the php code which processes the new user request... $accesslv1=$_POST['accesslv']; //reading the POST variable from the create userpage //determine what access level this user has if(accesslv1=="admin"){ $accesslv=1; //this would be an admim user } elseif(accesslv1=="manager"){ $accesslv=2; //this would be a manager } else{ $accesslv=3; //this would be a user } for debugging, i popped this at the end instead of a redirect... echo "Username: " .$username . "<br> AccessLevel: " .$accesslv1 ." (lv" .$accesslv .")"; and all i get is this... This should read manager (lv2), but for whatever reason its not doing! thanks in advance for any help guys!!
  5. i know it is, and i thought != was the answer, but my script isnt working properly and i thought perhaps i'd got it wrong. Problem must be elsewhere! Thanks for the reply Jessica
  6. Hey guys, I'm used to being able use if statements that say 'if value is anything other than x then...' (if variable <> test, do something). Is it possible to use IF in the same way in PHP? If so, how? Thanks in advance!
  7. hey guys! I was wondering what the best or preferred way of only showing certain pages to users when logged in is? I tried declaring a session variable 'active' as TRUE, and then checking for it on my 'logged in' page, but that didnt seem to work I used this in the login page on successful login... session_start(); $_SESSION['active'] ='TRUE'; header("location:userhome.php"); When i log in, i dont get any errors and it redirects me to userhome.php, which is... <?php include("session.php"); $sessioncheck = $_SESSION['active']; echo 'You are logged in!! Session status is: ' . $sessioncheck ; ?> and session.php looks like this... <?php session_start(); if ($_SESSION['active'] != 'true') { header("location:login.php?response=4"); exit(); } ?> but "logged in" or not, i get "You are logged in! Session status is: ", with no actual variable. am i overlooking something? Any help is appriciated!! Thanks
  8. I nailed it with this... $dbcon = mysql_connect("$host","$username","$password"); if (!$dbcon) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$db_name", $dbcon); $query_result = mysql_query("SELECT * FROM $tbl_name WHERE username='$myusername'"); while($result_array = mysql_fetch_array($query_result)) { $accesslv=($result_array['accesslv']); if($accesslv==1){ header("location:adminhome.php"); } else if($accesslv==2){ header("location:managerhome.php"); } else if($accesslv==3){ header("location:userhome.php"); } echo $accesslv; echo "<br />"; } mysql_close($dbcon); Thanks for help! If i want to do multiple checks on a record before proceeding, is it best to mimimise mysql connections and get all the info in one go rather than opening a connection to check one thing then opening another connection to check the next?
  9. Hey guys, I'm trying to figure out the best way to do an if statement based on the value of "accesslevel", which is a row in my mysql database. At the minute my project has multiple login pages for various types of user, but i figured if i threw an extra row into my users table containing their access level (ie 1=admin,2=manager,3=user) then i could just have the 1 login page, check this accesslevel and redirect to the appropriate page on successful login based on their access level. I'm a bit of a php noob jumping in at the deepend, so apologies!! but yeah, Any help appriciated!
  10. That was exactly the problem!!!! Thanks for your help!!
  11. ahhh i have solved my problem! I didnt realise i had to include <?php and ?> on the include file, so that was missing! added in, and worked straight away!! Thanks guys!!!
  12. ahhh so i did! infact, i edited the username and password as i was typing the post to be safe and deleted an extra character. it is there in the actual 'usersmysql.php' file. I should also add that when i copy and paste the exact contents of the usersmysql.php into the main script and comment out the include, it works straight away.
  13. Hey guys, Quick one for you. I'm trying to use include for my db connection variables, but for some unknown reason, it wont have any of it. so my file 'usersmysql.php' contains this... $host="127.0.0.1"; $username="globaluser"; $password="d4TXz4ATHgcvqJx"; $db_name="project1"; $tbl_name="useraccounts"; and my main script is this... <?php include("usersmysql.php"); mysql_connect("$host", "$username", "$password")or die("There was a problem connecting to the database"); mysql_select_db("$db_name")or die("cannot select DB"); $myusername=$_POST['loginusr']; $myplainpassword=$_POST['loginpwd']; $mypassword=md5($myplainpassword); $myusername = stripslashes($myusername); $myusername = mysql_real_escape_string($myusername); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ session_register("myusername"); session_register("mypassword"); header("location:userhome.php"); } else { //$interact = 'Invalid username and/or password'; $_SESSION['interact'] = $count; header("location:login.php?response=1"); } ?> But when i test this, all i get is a dead output... $host="127.0.0.1"; // Host name $username="globaluser; // Mysql username $password="d4TXz4ATHgcvqJx"; // Mysql password $db_name="project1"; // Database name $tbl_name="useraccounts"; // Table name There was a problem connecting to the database The variables listed in the output are correct, so it obviously reads the include file, but i cant see why its not actioning it correclty. Any help appriciated!!
  14. thats awesome thank you... the GIF's now work, but still no luck with PNG files. whats this bit doing? ($_FILES["uploaded_file"]["type"] == "image/jpeg") Does that restrict the file type or something?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.