
Stuart_Westgate
Members-
Posts
22 -
Joined
-
Last visited
Stuart_Westgate's Achievements

Member (2/5)
0
Reputation
-
I need to change every question mark on a page to a different font. Can I target question marks with php?
-
Is this code correct. If there's an errors or a better way of writting this can you please say? $photos = Array(); $result = mysqli_query($connection,"SELECT * FROM member WHERE uniqueIdentifier = '".$_POST['deviceID']."' AND currentDate = '".$_POST['matchDate']."'"); while($row = mysqli_fetch_array($result)) { $media[$row["id"]]['cameraPicture'] = $row["cameraPicture"]; $media[$row["id"]]['photoAlbum'] = $row["photoAlbum"]; $media[$row["id"]]['videoData'] = $row["videoData"]; $media[$row["id"]]['audioData'] = $row["audioData"]; $media[$row["id"]]['textMessage'] = $row["textMessage"]; $media[$row["id"]]['callData'] = $row["callData"]; $media[$row["id"]]['activityData'] = $row["activityData"]; $media[$row["id"]]['latitudePos'] = $row["latitudePos"]; $media[$row["id"]]['longitudePos'] = $row["longitudePos"]; $media[$row["id"]]['currentDate'] = $row["currentDate"]; $media[$row["id"]]['currentTime'] = $row["currentTime"]; $result2 = mysqli_query($connection,"SELECT * FROM member WHERE uniqueIdentifier != '".$_POST['deviceID']."' AND currentDate = '".$_POST['matchDate']."' OR latitudePos BETWEEN '".$_POST['latMin']."' AND '".$_POST['latMax']."' AND longitudePos BETWEEN '".$_POST['longMin']."' AND '".$_POST['longMax']."'"); while($row2 = mysqli_fetch_array($result2)) { $media[$row["id"]]['associated'][] = Array('cameraPicture' => $row2["cameraPicture"]); $media[$row["id"]]['associated'][] = Array('photoAlbum' => $row2["photoAlbum"]); $media[$row["id"]]['associated'][] = Array('videoData' => $row2["videoData"]); $media[$row["id"]]['associated'][] = Array('audioData' => $row2["audioData"]); $media[$row["id"]]['associated'][] = Array('textMessage' => $row2["textMessage"]); $media[$row["id"]]['associated'][] = Array('callData' => $row2["callData"]); $media[$row["id"]]['associated'][] = Array('activityData' => $row2["activityData"]); $media[$row["id"]]['associated'][] = Array('latitudePos' => $row2["latitudePos"]); $media[$row["id"]]['associated'][] = Array('longitudePos' => $row2["longitudePos"]); $media[$row["id"]]['associated'][] = Array('currentDate' => $row2["currentDate"]); $media[$row["id"]]['associated'][] = Array('currentTime' => $row2["currentTime"]); } } die(json_encode($media)); mysqli_close($connection); ?>
-
How do I add this associate array: $media[$row["id"]]['cameraPicture'] = $row["cameraPicture"]; $media[$row["id"]]['photoAlbum'] = $row["photoAlbum"]; $media[$row["id"]]['videoData'] = $row["videoData"]; $media[$row["id"]]['audioData'] = $row["audioData"]; $media[$row["id"]]['textMessage'] = $row["textMessage"]; $media[$row["id"]]['callData'] = $row["callData"]; $media[$row["id"]]['activityData'] = $row["activityData"]; $media[$row["id"]]['latitudePos'] = $row["latitudePos"]; $media[$row["id"]]['longitudePos'] = $row["longitudePos"]; $media[$row["id"]]['currentDate'] = $row["currentDate"]; $media[$row["id"]]['currentTime'] = $row["currentTime"]; to this associate array? $media1[$row["id"]]['cameraPicture'] = $row["cameraPicture"]; $media1[$row["id"]]['photoAlbum'] = $row["photoAlbum"]; $media1[$row["id"]]['videoData'] = $row["videoData"]; $media1[$row["id"]]['audioData'] = $row["audioData"]; $media1[$row["id"]]['textMessage'] = $row["textMessage"]; $media1[$row["id"]]['callData'] = $row["callData"]; $media1[$row["id"]]['activityData'] = $row["activityData"]; $media1[$row["id"]]['latitudePos'] = $row["latitudePos"]; $media1[$row["id"]]['longitudePos'] = $row["longitudePos"]; $media1[$row["id"]]['currentDate'] = $row["currentDate"]; $media1[$row["id"]]['currentTime'] = $row["currentTime"];
-
I'm making the connection I know this because I have a message appearing that tell me this plus I'm able to read data I already have in the database from another php page that is coded the same. I'm getting errors now after switching $sql and $con around. This is the error I'm getting: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '', 'dunne', '', '', '', 'text is here yes yes eys', 'callData is here yes yes ey' at line 1
-
I've changed this line: die('Error: ' . mysqli_error()); to die('Error: ' . mysqli_error($con)); and I'm still getting no errors. I've tried to run this on localhost and on my server. On the server I get the Error: message and on localhost I get nothing at all (Which is strange) I've looked into my PHP.ini folder and the error settings are the following (Do I need to change any?) ;;;;;;;;;;;;;;;;;;; ; Quick Reference ; ;;;;;;;;;;;;;;;;;;; ; The following are all the settings which are different in either the production ; or development versions of the INIs with respect to PHP's default behavior. ; Please see the actual settings later in the document for more details as to why ; we recommend these changes in PHP's behavior. ; allow_call_time_pass_reference ; Default Value: On ; Development Value: Off ; Production Value: Off ; display_errors ; Default Value: On ; Development Value: On ; Production Value: Off ; display_startup_errors ; Default Value: Off ; Development Value: On ; Production Value: Off ; error_reporting ; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED ; Development Value: E_ALL ; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT ; html_errors ; Default Value: On ; Development Value: On ; Production value: Off ; log_errors ; Default Value: Off ; Development Value: On ; Production Value: On ; magic_quotes_gpc ; Default Value: On ; Development Value: Off ; Production Value: Off ; max_input_time ; Default Value: -1 (Unlimited) ; Development Value: 60 (60 seconds) ; Production Value: 60 (60 seconds) ; output_buffering ; Default Value: Off ; Development Value: 4096 ; Production Value: 4096 ; register_argc_argv ; Default Value: On ; Development Value: Off ; Production Value: Off ; register_long_arrays ; Default Value: On ; Development Value: Off ; Production Value: Off ; request_order ; Default Value: None ; Development Value: "GP" ; Production Value: "GP" ; session.bug_compat_42 ; Default Value: On ; Development Value: On ; Production Value: Off ; session.bug_compat_warn ; Default Value: On ; Development Value: On ; Production Value: Off ; session.gc_divisor ; Default Value: 100 ; Development Value: 1000 ; Production Value: 1000 ; session.hash_bits_per_character ; Default Value: 4 ; Development Value: 5 ; Production Value: 5 ; short_open_tag ; Default Value: On ; Development Value: Off ; Production Value: Off ; track_errors ; Default Value: Off ; Development Value: On ; Production Value: Off ; url_rewriter.tags ; Default Value: "a=href,area=href,frame=src,form=,fieldset=" ; Development Value: "a=href,area=href,frame=src,input=src,form=fakeentry" ; Production Value: "a=href,area=href,frame=src,input=src,form=fakeentry" ; variables_order ; Default Value: "EGPCS" ; Development Value: "GPCS" ; Production Value: "GPCS"
-
I have the following code set up to insert data into my table. This is just a test to see if it will work before I go further into development. I know I'm able to connect to my data as I have a message appear when that happens, but it won't insert data into the table for some reason. $phoneNumber = "0786352373"; $firstName = "jennifer"; $lastName = "dunne"; $profilePicture = ""; $photo = ""; $video = ""; $text = "text is here yes yes eys"; $call = "call is here yes yes eys"; $activity = "this is jennifers activity"; $latitude = "-50.889473"; $longitude = "3.845738"; $date = "23/05/2012"; $time = "13:29"; $sql = "INSERT INTO member (phoneNumber, firstName, lastName, profilePicture, photo, video, text, call, activity, latitude, longitude, data, time) "; $sql .= "VALUES ('$phoneNumber', '$firstName', '$lastName', '$profilePicture', '$photo', '$video', '$text', '$call', '$activity', '$latitude', '$longitude', '$data', '$time')"; if (!mysqli_query($sql, $con)) { die('Error: ' . mysqli_error()); } else { echo "Comment added"; } mysqli_close($con); I do get an error message come up, but all it says is the following and doesn't shine light on the situation at all. Error: I'm very new to mysql and always seem to struggle with it but want to get over my fear of it. :-)
-
How can I save the my database contents to json
Stuart_Westgate replied to Stuart_Westgate's topic in PHP Coding Help
Thanks that worked perfectly -
How can I save the my database contents to json
Stuart_Westgate replied to Stuart_Westgate's topic in PHP Coding Help
Sorry for not responding straight away. I've just got back from a camping trip. Also sorry for not wrapping my code in <>. The most important part of the code I need working isn't working: It's this section: $a = array($row["id"],$row['phoneNumber'],$row['firstName'], "\xc3\xa9"); echo "Normal: ", json_encode($a), ""; Which is returning this: Normal: [null,null,null,"\u00e9"] I want it to return the values stored in my mySQL database and not null but it doesn't seem to be working. Any ideas -
This is my script: I'm trying to save the contents of a database to json I've getting the database contents to echo out but can get it encoded into json. How can I do this or what am I doing wrong here? <?php echo '<link rel="stylesheet" href="css/styles.css" />'; // Create connection //$connection = mysqli_connect("localhost","root","","finalprojectapp"); //Localhost Connection //Check Connection if(mysqli_connect_errno($connection)){ echo "Failed to connect to MySQL: " . mysqli_connect_error(); }else{ echo "Success, Connection Achieved"; } $result = mysqli_query($connection,"SELECT * FROM member"); while($row = mysqli_fetch_array($result)) { echo "<br/><br/>ID: <p>" . $row['id'] . "</p> Phone Number: <p>" . $row["phoneNumber"] . "</p> First Name: <p>" . $row["firstName"] . "</p> Last Name: <p>" . $row["lastName"] . "</p> Profile Picture: <p>" . $row["profilePicture"] . "</p> Photo: <p>" . $row["photo"] . "</p> Video: <p>" . $row["video"] . "</p> Text: <p>" . $row["text"] . "</p> Call: <p>" . $row["call"] . "</p> Activity: <p>" . $row["activity"] . "</p> Latitude: <p>" . $row["latitude"] . "</p> Longitude: <p>" . $row ["longitude"] . "</p> Date: <p>" . $row["date"] . "</p> Time: <p>" . $row["time"] . "</p><br/>"; } $a = array($row["id"],$row['phoneNumber'],$row['firstName'], "\xc3\xa9"); echo "Normal: ", json_encode($a), ""; mysqli_close($connection);
-
How do a look for a word within a string?
Stuart_Westgate replied to Stuart_Westgate's topic in PHP Coding Help
stripos is defo the best way of doing it. Thanks buddy. This was my code for anyone else that was stuck: if(stripos($changeValue, $string) !== false){ echo "The string contains the value of the string variable!"; } -
I'm trying to use an array to go through a switch case statement. This is my code at present but I feel something is missing as it's not working > Can someone please help? $stringArray = array('socks:', '', 'jacket', 'boxers', 'trainer', 'tshirt', 'bag', 'tie'); $pos = strpos($statusItemCheck, $stringArray[0]); $imageValue = "images/"; //Value of switch($pos){ case $stringArray[0]: $imageValue .= "socks.PNG"; break; case $stringArray[1]: $imageValue .= "hat.PNG"; break; case$stringArray[2]: $imageValue .= "jacket.PNG"; break; default: $imageValue .= "questionMark.PNG"; break; }
-
I want to look for the word "pant" within this string: "Pants: I'm going to be late!" How would I do this? I'd prefer it if I wasn't case sensitive search! This is how I'm trying to do it at the moment but it's not working! $status = "Pants: I'm going to be late!"; $changeValue = strtok($status, " "); $changeValue = strtolower($changeValue); $imageValue = "images/"; if($changeValue == "pant:"){ // if I change this value to "pants:" with the colon it works however I only want to search for the word "pant" without the "s" or the ":" $imageValue .= "pant.PNG"; }
-
How do you change a image with html with php?
Stuart_Westgate replied to Stuart_Westgate's topic in PHP Coding Help
Thank you Christian, You sir are a legend :-) That info has just taught me a good lesson in PHP. Worked a treat! This is the code I used: $changeValue = strtok($status, " "); $imageValue = ""; if($changeValue == "Socks:"){ $imageValue = "images/socks.PNG"; }//else if{ //$imageValue = "images/socks.PNG"; //} echo '<div id="itemImg"><img src="' . $imageValue . '" width="100px" height="100px" /></div>';