Skip to main content

Posts

JSON PHP data returning null

i am trying to fetch a PHP script using AJAX and return the values as JSON. For some reason, my script fails and i am trying to figure out the problem. When i enter a value form the database into the address bar, like www.someaddress/post.php?kinaseEntry=aValue i get a json out put like so; {"kinaseSKU":null,"url":null,"molecularWeight":null,"tracerSKU":null,"antiSKU1":"antiSKU1","antiSKU2":"antiSKU2","bufferSKU":"bufferSKU","tracerConc":null,"assayConc":null} My php file looks like so; <?php //Include connection to databse require_once 'connect.php'; $kinase = mysql_real_escape_string ($_POST["kinaseEntry"]); mysql_query('SET CHARACTER SET utf8'); $findKinase = "SELECT * FROM kbaData where cleanSKU = '" .$kinase. "' "; if ($result = mysql_query($findKinase)) { $row = mysql_fetch_arra

How can I add a variable to an array?

How can I add a variable to an array? Let say I have variable named $new_values : $new_values=",543,432,888" And now I would like to add $new_values to function. I tried in that way: phpfunction1(array(114,763 .$new_values. ), $test); but I got an error Parse error: syntax error, unexpected T_VARIABLE, expecting ')' How my code should look if I would like to have array(114,763,543,432,888) ?

get function name that called function without arguments

I have a class admin_model with the private method admin_form() There are a number of other public functions that call this method. Is there a way to get the name of the function that called admin_form() from INSIDE admin_form() ? I could easily add an argument when calling admin_form() like: $this -> admin_form(__FUNCTION__); then inside admin_form($caller) I have the caller. It will be $caller But i was hoping there was a way to do this WITHOUT passing arguments. Any Ideas?? Cheers, Alex

mail() function in PHP does not works in local system

I am using php mail(). I have been working in my local system, I mean not a domain. is shows php error as bellow Error Message: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() I tried this http://pastebin.com/SNcnPi5c to check but does not works fine what i need to change?

flash object not displaying in firefox

When i first load the page the flash container div is set to display:none, i then apply some jQuery to .fadeIn() and set the div heigth and width size. Fine. But within this div i embed the flash object this way: <object width="692" height="389"> <param name="allowfullscreen" value="true" /> <param name="allowscriptaccess" value="always" /> <param name="wmode" value="transparent"> <param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=<?php the_field('vimeo'); ?>&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" /> <embed src="http://vimeo.com/moogaloop.swf?clip_id=<?php the_field('vimeo'); ?>&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_

Converting MySQL to PDO

I've been advised a couple of times on here to start changing my code to PDO and I've finally got round to doing it. My problem is that I'm having incredible difficulty with converting my existing login script. For the last few lines of the code below (after the line $result = $query->fetchAll(); ) I haven't been able to find any resources online that could help me re-write it: $username = $_POST['username']; $password = $_POST['password']; $db=getConnection(); $username = mysql_real_escape_string($username); $query = $db->prepare( "SELECT password, salt, 'employer' as user_type FROM JB_Employer WHERE Username = '$username' UNION SELECT password, salt, 'jobseeker' as user_type FROM JB_Jobseeker WHERE User_Name = '$username'"); $result = $query->fetchAll(); $qData = mysql_fetch_array($result, MYSQL_ASSOC); $hash = hash('sha256', $qData['salt'] . hash('sha256', $password) ); if (